Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npx cannot find module 'webpack'

I'm trying to test a custom Webpack configuration. I've read that instead of typing node ./node_modules/webpack/bin/webpack.js, I can use npx webpack. But I can't seem to get it to work.

user@comp:~/raw> npx webpack
The CLI moved into a separate package: webpack-cli.
Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D

When I switch to running npx webpack-cli, I get a different error:

user@comp:~/> npx webpack-cli
npx: installed 489 in 19.186s
Cannot find module 'webpack'
like image 659
Lizi Avatar asked Nov 07 '22 08:11

Lizi


1 Answers

Please install 'webpack-cli' in addition to webpack itself to use the CLI.
-> When using npm: npm install webpack-cli -D
-> When using yarn: yarn add webpack-cli -D

Basically that's all. After you've installed the webpack-cli just use

npx webpack
like image 115
scor4er Avatar answered Nov 14 '22 21:11

scor4er