我下载了现有的Web项目并尝试运行: webpack --watch-进度
但它一直在说:
webpack --watch --progress
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm WARN @ngtools/webpack@1.10.2 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/core@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/forms@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror@1.1.3 requires a peer of @angular/common@^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware@1.12.2 requires a peer of webpack@^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server@2.11.3 requires a peer of webpack@^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ webpack-cli@3.1.2
added 2 packages from 2 contributors, removed 1 package, updated 3 packages and audited 24726 packages in 16.453s
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at runCommand.then (...\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:142:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
WebPack是否需要特定的NPM /节点版本? (也许新版本与旧版本不兼容。)
答案 0 :(得分:0)
https://stackoverflow.com/a/41305211
Oleg Pro的帮助帮了我大忙,特别是如他在第3部分中所述,将node_modules/.bin
放在了我的路上。
在使用webpack(4.29.0)和Node(v10.15.0)版本时,我在项目目录中找不到node_modules/.bin/webpack-cmd
(如他在1中指定的那样)。我找到了node_modules/.bin/webpack-cli
。
安装似乎可以正常工作,因为随后我使用webpack安装了Vue,Vue又生成了app.vue
和hello_vue.js
文件。但是,vue --version
返回的vue:command
未找到,所以我采取了一种观望的态度。