有时使用私有仓库编译部署时,npm install
安装依赖遇到以下问题
找不到对应的包,是因为 nexus 部署的npm 源延迟,未同步到最新的 npm 包,所以对应版本找不到
解决方案:
方案 1
根源是 nexus 同步问题,如解决可以无此问题。临时方案可以清楚 nexus 缓存来解决
方案 2
项目使用的 npm 包依赖未锁定版本,可以将 package-lock.json
可以提交到代码仓库。此时注意 CI/CD 环境部署时,对应环境的 ~/.npmrc不能设置 package-lock 为 false
可以通过在 npm install 之前修改配置
npm config set package-lock true
注意:如果本地设置 false 会导致不生成 package-lock.json 文件
详细错误如下:
[2021-05-26T03:51:42.281Z] + rm -rf ./node_modules
[2021-05-26T03:51:42.281Z] + npm config set package-lock true
[2021-05-26T03:51:42.281Z] + export UI_RUNTIME_ENV=dev
[2021-05-26T03:51:42.281Z] + UI_RUNTIME_ENV=dev
[2021-05-26T03:51:42.281Z] + npm install
[2021-05-26T03:51:47.549Z] npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
[2021-05-26T03:51:50.064Z] npm WARN deprecated fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
[2021-05-26T03:51:58.152Z] npm WARN deprecated @hapi/joi@16.1.8: Switch to 'npm install joi'
[2021-05-26T03:52:03.399Z] npm WARN deprecated har-validator@5.1.5: this library is no longer supported
[2021-05-26T03:52:08.695Z] npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
[2021-05-26T03:52:15.253Z] npm WARN deprecated @hapi/formula@1.2.0: Moved to 'npm install @sideway/formula'
[2021-05-26T03:52:15.253Z] npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
[2021-05-26T03:52:15.253Z] npm WARN deprecated @hapi/pinpoint@1.0.2: Moved to 'npm install @sideway/pinpoint'
[2021-05-26T03:52:15.253Z] npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
[2021-05-26T03:52:15.253Z] npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
[2021-05-26T03:52:18.539Z] npm WARN deprecated @types/anymatch@3.0.0: This is a stub types definition. anymatch provides its own type definitions, so you do not need this installed.
[2021-05-26T03:52:36.634Z] npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
[2021-05-26T03:52:39.902Z] npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
[2021-05-26T03:52:39.902Z] npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[2021-05-26T03:52:40.829Z] npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
[2021-05-26T03:52:41.756Z] npm WARN deprecated @types/vfile-message@2.0.0: This is a stub types definition. vfile-message provides its own type definitions, so you do not need this installed.
[2021-05-26T03:52:44.275Z] npm ERR! code ETARGET
[2021-05-26T03:52:44.275Z] npm ERR! notarget No matching version found for es-abstract@^1.18.2
[2021-05-26T03:52:44.275Z] npm ERR! notarget In most cases you or one of your dependencies are requesting
[2021-05-26T03:52:44.275Z] npm ERR! notarget a package version that doesn't exist.
[2021-05-26T03:52:44.275Z] npm ERR! notarget
[2021-05-26T03:52:44.275Z] npm ERR! notarget It was specified as a dependency of 'string.prototype.matchall'
[2021-05-26T03:52:44.275Z] npm ERR! notarget
[2021-05-26T03:52:44.275Z]