1、问题描述
小程序发布的时候一般都会执行一次 npm install 命令在新的环境下安装依赖,再进行构建发布,有可能会报
certificate has expired 错误
开始上传项目...tdyhw npm ERR! code CERT_HAS_EXPIRED npm ERR! errno CERT_HAS_EXPIRED npm ERR! request to https://registry.npm.taobao.org/xml2js/download/xml2js-0.4.23.tgz?cache=0&sync_timestamp=1599054229598&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fxml2js%2Fdownload%2Fxml2js-0.4.23.tgz failed, reason: certificate has expired npm ERR! A complete log of this run can be found in: npm ERR! /home/yhsp/.npm/_logs/2024-12-16T03_35_28_018Z-debug-0.log > quanyun@1.0.0 tdyhw > cross-env NODE_ENV=tdyhw node ./ci.js 20241216-tdyhw 5 wx20c0bd9b0ca82ff1 发布租户:tdyhw, 分支: master, git sha: 1071e30, git log: Update package-lock.json sh: cross-env: 未找到命令 编译项目异常 |
或者报 network request failed
项目更新成功 开始上传项目...tdyhw npm ERR! code ENOTFOUND npm ERR! syscall getaddrinfo npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.nlark.com/xmlbuilder/download/xmlbuilder-11.0.1.tgz failed, reason: getaddrinfo ENOTFOUND registry.nlark.com npm ERR! network This is a problem related to network connectivity. npm ERR! network In most cases you are behind a proxy or have bad network settings. npm ERR! network npm ERR! network If you are behind a proxy, please make sure that the npm ERR! network 'proxy' config is set properly. See: 'npm help config' npm ERR! A complete log of this run can be found in: npm ERR! /home/yhsp/.npm/_logs/2024-12-16T03_06_14_111Z-debug-0.log > quanyun@1.0.0 tdyhw > cross-env NODE_ENV=tdyhw node ./ci.js 20241216-tdyhw 5 wx20c0bd9b0ca82ff1 发布租户:tdyhw, 分支: master, git sha: a5eb6f0, git log: Merge branch 'v5.9.0/fix-clx-20241214' into 'master' v5.9.0/fix-clx-20241214到 master 增加发布脚本tdyhw See merge request mall/mall-member-mini-program!6 sh: cross-env: 未找到命令 编译项目异常 |
2、解决方案
这两个都是网络问题导致的,一个是淘宝的npm 镜像仓库换地址了,一个是不再提供这个第三方包。
解决方式是找到工程目录下的 package-lock.json 文件,把里面有问题的域名统一替换为 https://registry.npmmirror.com 。