webpack-babel-multi-target-plugin
webpack-babel-multi-target-plugin copied to clipboard
'babel-loader' cannot be found when using npm 7.20.3+
With a simple package.json: https://github.com/Artur-/webpack-babel-test/blob/main/package.json
npm install
with npm 7.20.2 and earlier will install babel-loader
as a top level module in node_modules
npm install
with npm 7.30.2 and newer will install babel-loader
as a webpack-babel-multi-target-plugin dependency in node_modules/webpack-babel-multi-target-plugin/node_modules
Because of this, a simple webpack configuration like https://github.com/Artur-/webpack-babel-test/blob/main/webpack.config.js will work fine with npm < 7.20.3 and fail with npm >= 7.20.3:
ERROR in Entry module not found: Error: Can't resolve 'babel-loader' in '/.../webpack-babel-test'
To reproduce the problem:
git clone https://github.com/Artur-/webpack-babel-test.git
cd webpack-babel-test
npx [email protected] install
node_modules/.bin/webpack
Works fine if you change the npm command to
npx [email protected] install