npm install --legacy-peer-deps

1,762 阅读1分钟

让我来水一篇文章

今天把代码合并到master分支

想像往常一样在jekins上一键打包构建

没想到打包的时候报错了。报错内容如下:

npm WARN old lockfile 

npm WARN old lockfile The package-lock.json file was created with an old version of npm,

npm WARN old lockfile so supplemental metadata must be fetched from the registry.

npm WARN old lockfile 

npm WARN old lockfile This is a one-time fix-up, please be patient...

npm WARN old lockfile 

npm ERR! code ERESOLVE

npm ERR! ERESOLVE unable to resolve dependency tree

npm ERR! 

npm ERR! While resolving: sign-vue@1.0.0

npm ERR! Found: webpack@3.12.0

npm ERR! node_modules/webpack

npm ERR!   dev webpack@"^3.6.0" from the root project

npm ERR! 

npm ERR! Could not resolve dependency:

npm ERR! peer webpack@"^4.36.0 || ^5.0.0" from sass-loader@10.2.0

npm ERR! node_modules/sass-loader

npm ERR!   dev sass-loader@"^10.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 /home/app02/.npm/eresolve-report.txt for a full report.



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

npm ERR!     /home/app02/.npm/_logs/2021-10-20T03_33_27_963Z-debug.log

script returned exit code 1

刚开始我以为是依赖源的问题,我就让后端多构建几次。

发现点了两三次都不行。后来查了查好像是npm版本的问题(什么npm7的blabla)

后来凭借俺过高的百度水平,发现了解决方法。链接如下:

stackoverflow.com/questions/6…

大意就是这个npm的beta版本 就下载一些对等依赖

这个命令npm install --legacy-peer-deps 和这个命令 npm install --force

会让你忽略对等的依赖 这两个依赖也有亿点点的区别 就靠各位百度工程师自行搜索了~

今天的文章就水到这里

see you