从缓存中获取时完整性不正确

Dou*_*son 51 yarnpkg

运行时yarn add --dev jest从缓存中获取错误完整性错误

全输出:

tests (master)$ yarn add --dev jest
yarn add v1.19.0
info No lockfile found.
[1/4] Resolving packages...
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > left-pad@1.3.0: use String.prototype.padStart()
[2/4] Fetching packages...
error Incorrect integrity when fetching from the cache
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
Run Code Online (Sandbox Code Playgroud)

我尝试删除node_modules,重新运行yarn installyarn add --dev jest但无济于事。

我该如何解决?

Dou*_*son 98

yarn cache clean

要解决此问题,请运行:

yarn cache clean
yarn add --dev jest
Run Code Online (Sandbox Code Playgroud)

纱线缓存文档中

yarn cache clean [<module_name...>]

运行此命令将清除全局缓存。下次运行纱线或安装纱线时,它将再次填充。此外,您可以指定一个或多个要清理的软件包。

您还可以使用查看缓存yarn cache dir

yarn cache dir

运行纱线缓存目录将打印出当前存储纱线全局缓存的路径。

  • “ yarn cache”命令都是关于“全局”缓存的。@imolit (2认同)

Jog*_*ogi 5

纱线缓存清洁没有帮助。我们必须降级服务器上的纱线版本。

事实证明,问题与使用私有包有关。

GitHub Yarnpkg -“从缓存中获取时完整性不正确”#7584


vel*_*lop 5

对于使用 heroku 并看到此错误的任何人:

  • 安装heroku cli
  • 登录方式 heroku login
  • heroku plugins:install heroku-repo
  • heroku repo:purge_cache -a $YOURAPPNAME

然后进行手动重建