css-loader: Cannot find module "!!./../node_modules/css-loader/ ...
I ran into this issue today and spent a lot of time figuring out why it is not working, but here is the error I get in inspector tools that I believe is related to css-loader:
Uncaught Error: Cannot find module "!!./../node_modules/css-loader/index.js!./../node_modules/sass-loader/index.js!./main.scss"
and this one in console:
ERROR in ./~/css-loader!./~/sass-loader?sourceMap!./style/main.scss Module build failed: @import './components/Story/story-editor'; ^ File to import not found or unreadable: ./components/Story/story-editor Parent style sheet: stdin in /home/rof/src/github.com/TeamDojo/DojoAdmin/style/main.scss (line 94, column 1) @ ./style/main.scss 4:14-125
This is how I use css loader inside my webpack:
var path = require('path');
var webpack = require('webpack');
var node_modules_dir = path.resolve(__dirname, 'node_modules');
module.exports = {
entry: [
'webpack/hot/dev-server',
'webpack-dev-server/client?http://localhost:8081',
path.resolve(__dirname, 'src/index.js')
],
output: {
path: path.resolve(__dirname, 'build'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.(js|jsx)$/,
exclude: [node_modules_dir],
loader: 'babel'
},
{
test: /\.scss$/,
exclude: [node_modules_dir],
loader: 'style!css!sass'
}]
},
devServer: {
historyApiFallback: true,
contentBase: './'
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"development"'
})
]
};
My project structure
...
src/
index.js
style/
main.scss
And I’m including my main.css file like this inside index.js
import '../style/main.scss';
node v: 5.6.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 13
- Comments: 26
Commits related to this issue
- Added -p parameter, see https://github.com/webpack-contrib/css-loader/issues/240 — committed to eHanlin/writing-pad by SparrowJang 7 years ago
I faced this problem also but this was because of the
node-sass
package.I previously used Node V4.5.0 and then switched to V6.7.0. And
node-sass
was built for V4.5.0. The error given by webpack wasn’t very clear, but I finally figured it out thanks to Protractor.I then ran
npm rebuild node-sass
and everything worked fine so far.Hope this help some of you
@IljaDaderko Ur npm version 3+ ? downgrade npm to 2.14.4 fix this problem for me
I had exactly the same error and the only fix was to do this but my build time has gone from 8 minutes up to 36 minutes
Same problem happened for me today, setting the following (downgrading releases) in package.json solved it: “caniuse-db”: “1.0.30000615”, “extract-text-webpack-plugin”: “2.0.0-beta.5”
Happens also when You have broken less file (ie missing variable)
rm node_modules -Rf
npm i
Running Node v. 11.6.0 and got this error.
I’m using scss, compiling it using Laravel-mix. I had some highly wierd results, when using relative paths (
../foo/bar
) and semi-absolute paths (/foo/bar
). It worked when I used absolute paths (http://example.org/for/bar
) - but is a shitty solution.… But then I discovered the tilde (
~
)!These didn’t work for me:
body { background: url("/wp-content/themes/themename/assets/img/menu-arrow.png"); }
body { background: url("../../assets/img/menu-arrow.png"); }
This worked (but is a shitty solution):
body { background: url("http://example.org/wp-content/themes/themename/assets/img/menu-arrow.png"); }
This solution worked and is good (notice the
~
in the beginning of the path).body { background: url("~/wp-content/themes/themename/assets/img/menu-arrow.png"); }
@clementprevot you are a life saver!! thanks a lot.
I faced a similar situation.
bundle.js:15761 Uncaught Error: Cannot find module "!!./../../node_modules/css-loader/index.js!./../../node_modules/style-loader/index.js!./../../node_modules/css-loader/index.js!./member.css"
My solution is configure loader include a not_exist_path, and it worked.
update: these seems to be a configure problem, In my case it appears when I specify loaders both in
require
and webpack.config.js. see Unknown word error when loading plain CSS (not Sass or Less)I found out that one of my css files was missing. Node and its errors… I lost half of the day reinstalling and clearing caches and files, and killing processes, and bunch of other stupid stuff. Why it just won’t say “xyz.css file is missing”?
@clementprevot That fixed it for me. Thanks!
nvm .Apparently jenkins box was using node 0.10.30 and updating node to a version 0.12 or higher fixed it.
Similar issue is happening to us.It works fine locally but when we deploy on other envs via jenkins we see this issue. Node version v4.2.4 .NPM version 3.8.9 Webpack version 1.13.2 Node and npm version did not change on the server though. This stopped working only recently so I don’t think downgrading the npm version would help us. It works fine when we build locally. I have the same node version and npm version on my machine as the jenkins box.
I had this issue when after ejecting from create-react-app, and adding scss to the webpack.dev.config.js.
I fixed it by adding the
.scss
to the exclude forurl-loader
, like the documentation says.