纱线安装:"Not a git repository" 获取包时出错

Yarn install: "Not a git repository" error when fetching packages

系统: Windows 10 64 位

我正在尝试使用存储库目录中的 yarn install --lock-file 构建一个 JavaScript 项目。当 yarn 尝试获取包时,它失败并显示以下错误消息:

Exit code: 128 Command: git Arguments: pull Directory: C:\Users\[UserDirectory]\AppData\Local\Yarn\Cache\v2.tmpf5ed3b3940e461693021bf6d9a7805d Output: fatal: not a git repository (or any of the parent directories): .git

我不明白为什么 yarn 试图在另一个目录中使用 git pull。你能解释一下 yarn 在这里做什么吗?

编辑: 起初,我猜想这一定是访问权限的问题,但 运行 提升访问权限后得到了相同的结果。 yarn install 也是如此,所以没有 --frozen-lockfile 标志。

对于任何 yarn 命令,我在我的回购协议中也遇到了同样的错误。

删除 Yarn 缓存 为我修复了 yarn

rm -rf C:\Users\<user>\AppData\Local\Yarn\Cache\v2.tmp\<hash>

编辑:改为 运行 yarn cache clean 更安全。