Tag Archives: postcss

[Solved] npm Error: Error: Cannot find module ‘postcss-loader‘

1. Problem
an error is reported when executing the command NPM run serve:

Error: Cannot find module 'postcss-loader'

2. Solution

The most thorough solution is to uninstall the current nodejs version and install the nodejs version consistent with the module version.

If you don’t want to reinstall nodejs, you can use the following methods:
install module:

npm install postcss-loader

If you continue to report errors:

npm ERR! Could not resolve dependency:
npm ERR! postcss-loader@"*" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/webpack
npm ERR!   peer webpack@"^5.0.0" from [email protected]
npm ERR!   node_modules/postcss-loader
npm ERR!     postcss-loader@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Take the – force or — legacy-peer-deps parameter after the command:

npm install postcss-loader --legacy-peer-deps