npm–踩坑–npm audit fix 解决方法

  • Post author:
  • Post category:其他


参考:

https://www.jianshu.com/p/f19ba506f664

看到 npm audit fix –force //强制安装最新的依赖项大概明白了上面问题的所在。

直接运行 –force 的行为不要学习,对于没能自动修复的问题,说明肯定出现了 SEMVER WARNING 之类的警告,这意味着推荐的修复版本存在让代码出问题的可能,主要发生在依赖包更改了 API 或者升级了大版本的情况,这时候就需要格外的小心甚至需要改动一些自己的代码了。

作者:liwuwuzhi

链接:https://www.jianshu.com/p/f19ba506f664

来源:简书

著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

解决方法:

知道了问题原因,那就可以去解决啦。

方法1: 用yarn 来安装,速度快还安全。

方法2:把 webpack-dev-server@3xx 退回以前版本

npm remove webpack-dev-server
npm install webpack-dev-server@2.9.1
npm run dev

报错:

npm ERR! code ERESOLVE

npm ERR! ERESOLVE unable to resolve dependency tree

npm ERR!

npm ERR! While resolving: myvue@1.0.0

npm ERR! Found: webpack@5.67.0

npm ERR! node_modules/webpack

npm ERR! dev webpack@”^5.67.0″ from the root project

npm ERR!

npm ERR! Could not resolve dependency:

npm ERR! peer webpack@”^2.0.0 || ^3.0.0″ from uglifyjs-webpack-plugin@1.1.2

npm ERR! node_modules/uglifyjs-webpack-plugin

npm ERR! dev uglifyjs-webpack-plugin@”^1.1.1″ from the root project

npm ERR!

npm ERR! Fix the upstream dependency conflict, or retry

npm ERR! this command with –force, or –legacy-peer-deps

npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

npm ERR!

npm ERR! See C:\Users\admin\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\admin\AppData\Local\npm-cache_logs\2022-01-22T10_26_58_098Z-debug.log

问题分析:npm 版本太高了

npm install npm@6 -g(@后跟版本号,若跟的是大版本,则更新到对应大版本最新的小版本)
npm install npm@6.14.14 -g(更新到指定版本)
npm install npm@6.14.10 -g
npm install npm -g(更新到最新版本)



版权声明:本文为qq_43470725原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。