我已经安装了webpack 4.5.0。
当我尝试运行webpack时,它抱怨它想要webpack-cli。
如果我运行npm install webpack-cli
,我会收到以下错误:
The CLI moved into a separate package: webpack-cli
Would you like to install webpack-cli? (That will run npm install -D webpack-cli) (yes/NO)yes
npm WARN deprecated nomnom@1.8.1: Package no longer supported. Contact support@npmjs.com for more info.
npm WARN webpack-cli@2.0.14 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
+ webpack-cli@2.0.14
updated 1 package in 14.175s
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at runCommand.then.result (/usr/local/lib/node_modules/webpack/bin/webpack.js:62:14)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7) code: 'MODULE_NOT_FOUND' }
有人看过这个并以某种方式解决了吗?
答案 0 :(得分:3)
它通过安装以下模块为我工作:
npm i -g webpack-cli
npm install --save-dev webpack
npm install --save-dev webpack-dev-server
答案 1 :(得分:0)
之所以发生这种情况,是因为尽管webpack-cli
可能是全局安装的,但尚未安装在当前项目中,并且某种程度上该项目无法使用全局安装的版本。
我通过在相关项目目录中运行npm install webpack-cli
来解决此问题。