jenkins构建一个vue时,一直出错,错误信息如下。
10:25:04 npm ERR! code ERESOLVE
10:25:04 npm ERR! ERESOLVE unable to resolve dependency tree
10:25:04 npm ERR!
10:25:04 npm ERR! While resolving: yuntang-testtable-vue@1.0.0
10:25:04 npm ERR! Found: webpack@3.12.0
10:25:04 npm ERR! node_modules/webpack
10:25:04 npm ERR! dev webpack@"^3.5.5" from the root project
10:25:04 npm ERR!
10:25:04 npm ERR! Could not resolve dependency:
10:25:04 npm ERR! peer webpack@"^4.0.0 || ^5.0.0" from less-loader@6.2.0
10:25:04 npm ERR! node_modules/less-loader
10:25:04 npm ERR! less-loader@"^6.0.0" from the root project
10:25:04 npm ERR!
10:25:04 npm ERR! Fix the upstream dependency conflict, or retry
10:25:04 npm ERR! this command with --force, or --legacy-peer-deps
10:25:04 npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
10:25:04 npm ERR!
10:25:04 npm ERR! See /root/.npm/eresolve-report.txt for a full report.
10:25:04
10:25:04 npm ERR! A complete log of this run can be found in:
10:25:04 npm ERR! /root/.npm/_logs/2022-09-05T02_25_04_604Z-debug.log
10:25:04 Build step 'Execute shell' marked build as failure
10:25:04 Finished: FAILURE
最初怀疑是node版本问题,因为开发的机器装的是node15,在这里用的是node16。但是换了node15,也不行,换了node17还不行,报错一样一样的。
最后,看了网友们的建议,加了一句--legacy-peer-deps这个好了。
npm install --legacy-peer-deps
npm run build
第一次构建成功了以后呢,--legacy-peer-deps这句话就可以删掉了,第二次就能直接
npm install
npm run build
就正常了。
当然了,我开始也试了半天,一直感觉跑不动,后来发现,是第一次运行npm install --legacy-peer-deps时,比较慢,得等个十来分钟,多等一会,第一次构建就好了。等到第一次构建成了以后,因为node_modules是可以复用的,所以以后再构建,速度就快多了。
版权声明:本文为lefen313原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。