在 CI 管道上构建项目以及尝试通过 Yarn 添加包时出现错误 "error Couldn't find package "XXX"
Error "error Couldn't find package "XXX" when building project on CI pipeline and when trying to add packages via Yarn
周末后回到我们的项目后,我的团队遇到了错误“error Couldn't find package '3d-view@^2.0.0' required by "gl-plot3d@^2.4.2" on "npm" registry." 在安装阶段我们的 CI 管道上。此外,尝试使用 yarn 添加包时会发生此错误,从而终止进程。
这个错误发生在我们项目的前端,在通过 yarn start 正常启动时不会出现。周末前的最后一次推送,一切正常,没有任何错误。
从安装命令开始的 CI 作业日志:
$ yarn install
yarn install v1.17.3
info No lockfile found.
[1/4] Resolving packages...
warning @material-ui/core > popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
warning moments > myconf > babel > babel-core > minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning moments > myconf > babel > babel-core > core-js@1.2.7: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning plotly.js > regl-splom > left-pad@1.3.0: use String.prototype.padStart()
warning plotly.js > ndarray-fill > cwise > static-module > through2 > xtend > object-keys@0.4.0:
warning plotly.js > point-cluster > bubleify > buble > os-homedir@2.0.0: This is not needed anymore. Use `require('os').homedir()` instead.
error Couldn't find package "3d-view@^2.0.0" required by "gl-plot3d@^2.4.2" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
我们的.gitlab-ci.yml代码:
stages:
- build
# - test
# - deploy
before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
- export GRADLE_USER_HOME=`pwd`/.gradle
- unset CI
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build backend:
image: gradle:6.1-jdk8
stage: build
script:
- cd backend
- gradle war
artifacts:
paths:
- backend/build/libs/*.jar
expire_in: 1 week
build frontend:
image: node:10.16.3
stage: build
script:
- cd frontend
- yarn install
- export NODE_OPTIONS=--max_old_space_size=4096
- yarn build
package.json 中的依赖项:
"dependencies": {
"@material-ui/core": "^4.9.0",
"@material-ui/icons": "^4.5.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"moments": "^0.0.2",
"plotly.js": "^1.52.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-plotly.js": "^2.4.0",
"react-scripts": "3.3.0"
}
我们不知道这是怎么发生的,因为在此期间没有人将任何东西推送到分支,并且当团队成员推送我们代码的清理版本而另一个人试图通过安装新包时被注意到纱.
我能够修复手动安装丢失的包:
sudo npm i git://github.com/mikolalysenko/3d-view
sudo npm install
问题似乎已经得到解决和修复,但这里有一些针对其他答案和我们自己的研究发现的可行解决方案,以防再次发生这种情况:
1) 在安装之前将 3d-view 添加到 yarn.lock 并添加 Plotly.js 或任何其他软件包:
"3d-view@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/3d-view/-/3d-view-2.0.0.tgz#831ae942d7508c50801e3e06fafe1e8c574e17be"
integrity sha1-gxrpQtdQjFCAHj4G+v4ejFdOF74=
dependencies:
matrix-camera-controller "^2.1.1"
orbit-camera-controller "^4.0.0"
turntable-camera-controller "^3.0.0"
2) 手动安装添加注册表的包:
yarn add 3d-view@2.0.0 --registry https://yarn.npmjs.org
感谢用户masseyb
npm i git://github.com/mikolalysenko/3d-view
感谢用户 Diogo Falcão
周末后回到我们的项目后,我的团队遇到了错误“error Couldn't find package '3d-view@^2.0.0' required by "gl-plot3d@^2.4.2" on "npm" registry." 在安装阶段我们的 CI 管道上。此外,尝试使用 yarn 添加包时会发生此错误,从而终止进程。
这个错误发生在我们项目的前端,在通过 yarn start 正常启动时不会出现。周末前的最后一次推送,一切正常,没有任何错误。
从安装命令开始的 CI 作业日志:
$ yarn install
yarn install v1.17.3
info No lockfile found.
[1/4] Resolving packages...
warning @material-ui/core > popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
warning moments > myconf > babel > babel-core > minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
warning moments > myconf > babel > babel-core > core-js@1.2.7: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
warning plotly.js > regl-splom > left-pad@1.3.0: use String.prototype.padStart()
warning plotly.js > ndarray-fill > cwise > static-module > through2 > xtend > object-keys@0.4.0:
warning plotly.js > point-cluster > bubleify > buble > os-homedir@2.0.0: This is not needed anymore. Use `require('os').homedir()` instead.
error Couldn't find package "3d-view@^2.0.0" required by "gl-plot3d@^2.4.2" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
我们的.gitlab-ci.yml代码:
stages:
- build
# - test
# - deploy
before_script:
# - echo `pwd` # debug
# - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
- export GRADLE_USER_HOME=`pwd`/.gradle
- unset CI
cache:
paths:
- .gradle/wrapper
- .gradle/caches
build backend:
image: gradle:6.1-jdk8
stage: build
script:
- cd backend
- gradle war
artifacts:
paths:
- backend/build/libs/*.jar
expire_in: 1 week
build frontend:
image: node:10.16.3
stage: build
script:
- cd frontend
- yarn install
- export NODE_OPTIONS=--max_old_space_size=4096
- yarn build
package.json 中的依赖项:
"dependencies": {
"@material-ui/core": "^4.9.0",
"@material-ui/icons": "^4.5.1",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"moments": "^0.0.2",
"plotly.js": "^1.52.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-plotly.js": "^2.4.0",
"react-scripts": "3.3.0"
}
我们不知道这是怎么发生的,因为在此期间没有人将任何东西推送到分支,并且当团队成员推送我们代码的清理版本而另一个人试图通过安装新包时被注意到纱.
我能够修复手动安装丢失的包:
sudo npm i git://github.com/mikolalysenko/3d-view
sudo npm install
问题似乎已经得到解决和修复,但这里有一些针对其他答案和我们自己的研究发现的可行解决方案,以防再次发生这种情况:
1) 在安装之前将 3d-view 添加到 yarn.lock 并添加 Plotly.js 或任何其他软件包:
"3d-view@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/3d-view/-/3d-view-2.0.0.tgz#831ae942d7508c50801e3e06fafe1e8c574e17be"
integrity sha1-gxrpQtdQjFCAHj4G+v4ejFdOF74=
dependencies:
matrix-camera-controller "^2.1.1"
orbit-camera-controller "^4.0.0"
turntable-camera-controller "^3.0.0"
2) 手动安装添加注册表的包:
yarn add 3d-view@2.0.0 --registry https://yarn.npmjs.org
感谢用户masseyb
npm i git://github.com/mikolalysenko/3d-view
感谢用户 Diogo Falcão