首页 前端知识 [npm] npm run dev 报错: This is probably not a problem with npm.

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

2024-05-13 10:05:58 前端知识 前端哥 573 350 我要收藏

报错关键词

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

成功运行!

转载请注明出处或者链接地址:https://www.qianduange.cn//article/8525.html
标签
评论
发布的文章

JQuery中的load()、$

2024-05-10 08:05:15

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!