I am trying to integrate my webpack project with sass-loader, but I am get this error:
Module build failed: Error: Cannot find module 'postcss'
I already installed postcss and postcss-loader with command:
npm install postcss postcss-loader --save-dev
After install, I continue to get the same error message. I test integrate my project only with css-loader and the same error occurs. I think postcss is a dependency of the css-loader.
In my webpack.config.js I use this configuration in my module.rules:
{
test: /\.scss$/,
use: [{
loader: "style-loader" // creates style nodes from JS strings
}, {
loader: "css-loader" // translates CSS into CommonJS
}, {
loader: "sass-loader" // compiles Sass to CSS
}
]
}
I installed all this loaders and node-sass, I don't know what I am doing wrong :(
npm install postcss --save-dev
. It should resolve your issues. – Copybooksass-loader
only requirenode-sass
to be installed as peerDependency. You don't needpostcss
to usesass-loader
. Anyway, try to install bothpostcss
andpostcss-loader
withnpm install --save-dev postcss postcss-loader
, and try to add{loader: "postcss-loader"}
in between yoursass-loader
andcss-loader
. – Maginpm install
to re-install all packages. – Magi