安装webpack和webpack-cli时出现的问题:
npm WARN webpack-cli@3.3.11 requires a peer of webpack@4.x.x but none is installed. You must install peer dependencies yourself.
问题翻译::
NPMWA RNwebpack-cli@3.3.11需要一个webpack@4.x.x的对等点,但没有安装。您必须自己安装对等依赖项。
原因:
安装时命令:npm install webpack -g
npm install webpack-cli -g
默认安装了webpack最新版本,导致安装的最新脚手架webpack-cli与webpack版本不匹配,导致安装错误
解决:
- 指定webpack安装版本:
npm install webpack@4.30.0 -g
- 指定webpack安装的版本如下:
npm install webpack-cli@3.3.2 -g
- 安装成功:
PS D:\developer\IdeaProjects\itcast-nodejs> npm install webpack@4.30.0 -g
D:\developer\node.js\npm_modules\webpack -> D:\developer\node.js\npm_modules\node_modules\webpack\bin\webpack.js
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules\webpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ webpack@4.30.0
added 323 packages from 198 contributors in 27.276s
PS D:\developer\IdeaProjects\itcast-nodejs> npm install webpack-cli@3.3.2 -g
D:\developer\node.js\npm_modules\webpack-cli -> D:\developer\node.js\npm_modules\node_modules\webpack-cli\bin\cli.js
> webpack-cli@3.3.2 postinstall D:\developer\node.js\npm_modules\node_modules\webpack-cli
> node ./bin/opencollective.js
**Thanks for using Webpack!
Please consider donating to our Open Collective
to help us maintain this package.**
Donate: https://opencollective.com/webpack/donate
npm WARN webpack-cli@3.3.2 requires a peer of webpack@4.x.x but none is installed. You must install peer dependencies yourself.
+ webpack-cli@3.3.2
added 206 packages from 126 contributors in 18.13s
在这里插入代码片