jenkins构建失败,查看构建日志,找到报错信息,部分内容粘贴如下:
npm WARN notsup Not compatible with your version of node/npm: less-loader@10.0.1
[0m[91mnpm WARN notsup Unsupported engine for style-loader@3.2.1: wanted: {"node":">= 12.13.0"} (current: {"node":"10.23.1","npm":"6.14.10"})
npm WARN notsup Not compatible with your version of node/npm: style-loader@3.2.1
[0m[91mnpm WARN notsup Unsupported engine for yargs@17.1.1: wanted: {"node":">=12"} (current: {"node":"10.23.1","npm":"6.14.10"})
npm WARN notsup Not compatible with your version of node/npm: yargs@17.1.1
[0m[91m
[0m[91mnpm ERR! code ETARGET
[0m[91mnpm ERR! notarget No matching version found for @babel/types@^7.15.4.
npm ERR! notarget[0m[91m In most cases you or one of your dependencies are requesting
npm ERR! [0m[91mnotarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget[0m[91m It was specified as a dependency of '@babel/helper-module-imports'
npm ERR! notarget[0m[91m
[0m[91m
npm ERR![0m[91m A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-09-03T10_04_40_582Z-debug.log
[0mThe command '/bin/sh -c npm install && npm ls vue vue-template-compiler && npm run build:prod' returned a non-zero code: 1
[Pipeline] }
[Pipeline] // withDockerRegistry
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
从报错信息来看,很明显是找不到所需版本的库文件。
通常公司会通过nexus这类工具定期将服务所需的依赖库拉取下来,存储到自己的nexus等私库,当其他服务更新了依赖库或依赖库的官方最近进行更新了操作,可能会导致另外一个服务所需的相关的依赖库也需要更新,而此时如果nexus还未到更新时间,就会导致报错信息中提示的这类问题。
要解决这个问题其实很简单,有多种方法:
- 要么手动更新nexus的依赖库
- 要么临时调整nexus的自动更新时间
- 要么把依赖库下载下来上传到nexus上
- 要么调整远程代理的地址
其中第一种方法和第二种方法亲自实践过,有效,只是稍微需要点时间;其他方法上需各位自行实践