切换到纱线零安装方法(请参阅https://yarnpkg.com/features/zero-installs),在运行 CI 管道时,我遇到了以下类型的错误:
/app/.pnp.cjs:47262
throw firstError;
^
Error: Required unplugged package missing from disk. This may happen when switching branches without running installs (unplugged packages must be fully materialized on disk to work).
Missing package: nodemon@npm:2.0.7
Expected package location: /app/.yarn/unplugged/nodemon-npm-2.0.7-7b95e46511/node_modules/nodemon/
.
.
.
Run Code Online (Sandbox Code Playgroud)
好的,这是预料之中的,因为这种方法不会运行yarn install,只是使用.yarn. 按照本段最后一点的建议https://yarnpkg.com/features/zero-installs#how-do-you-reach-this-zero-install-state-youre-advocating-for我调整了我的.gitignore和.dockerignore文件包括这个:
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/unplugged
Run Code Online (Sandbox Code Playgroud)
因此,拔出的文件夹应该能够提交到存储库,并在 CI 管道期间可用。但正如你所看到的,拔出的文件夹中每个包的文件仍然是灰色的,无法提交。
即使在检查了所有文件之后,输出git status --ignore仍然列出了目录:unplugged.gitignore
.yarn/.DS_Store
.yarn/build-state.yml
.yarn/cache/.gitignore
.yarn/install-state.gz …Run Code Online (Sandbox Code Playgroud)