[npm] npm run dev 报错: This is probably not a problem with npm.

报错关键词

This is probably not a problem with npm. There is likely additional logging output above.

npm WARN thread-loader@2.1.3 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

环境

开发工具:IDEA
Node.js: 14.18.2
npm: 6.14.15
vue版本:
vue : ^2.6.10 ,
vue-router : ~3.1.3 ,
vuex : ^3.0.1 ,
webpack版本: 5版本

过程

发现问题

今天拉了新项目 npm i安装成功之后 运行npm run dev报错,如下

'vue-cli-service' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bys-web@4.5.2 dev: `vue-cli-service serve --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bys@4.5.2 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\PC\AppData\Roaming\npm-cache\_logs\2023-06-19T12_00_23_770Z-debug.log

分析问题

刚刚的npm i安装后 报了一堆警告 意思都是webpack没有对应的版本 如下

npm WARN fork-ts-checker-webpack-plugin@6.5.3 requires a peer of typescript@>= 2.7 but none is installed. You must install peer dependencies yourself.
npm WARN ts-loader@8.4.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
npm WARN webpack-filter-warnings-plugin@1.2.1 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN acorn-import-assertions@1.9.0 requires a peer of acorn@^8 but none is installed. You must install peer dependencies yourself.
npm WARN less-loader@5.0.0 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-loader@2.2.1 requires a peer of webpack@>=2.0.0 <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @intervolga/optimize-cssnano-plugin@1.0.6 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN cache-loader@2.0.1 requires a peer of webpack@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN mini-css-extract-plugin@0.8.2 requires a peer of webpack@^4.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN thread-loader@2.1.3 requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

所以 需要安装这里面出现次数最多的版本的webpack 就是4.0.0
问题原因
很多包依赖 webpack4版本,通过命令下载的webpack是5版本,没法用
所以当前安装的webpack版本太高 需要手动降低版本

解决问题

解决方法
卸载当前webpack 再安装webpack4.0.0
命令:
npm uninstall webpack
npm install webpack@^4.0.0 --save-dev

成功运行!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值