npm WARN webpack-cli@3.3.11 requires a peer of webpack@4.x.x but none is installed. You must install

本文详细介绍了在安装webpack和webpack-cli时遇到的版本不匹配问题,解释了错误信息的含义,并提供了具体的解决步骤,包括如何指定版本进行安装。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装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版本不匹配,导致安装错误
解决:

  1. 指定webpack安装版本:
			npm install webpack@4.30.0 -g
  1. 指定webpack安装的版本如下:
			npm install webpack-cli@3.3.2 -g
  1. 安装成功:
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
在这里插入代码片
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值