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

时间:2019-09-30 17:36:39

标签: 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.

我尝试删除node_modules,然后重新运行yarn installyarn add --dev jest

我该如何解决?

6 个答案:

答案 0 :(得分:102)

yarn cache clean

要解决此问题,请运行:

yarn cache clean
yarn add --dev jest

来自yarn cache documentation

  

yarn cache clean [<module_name...>]

     

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

您还可以使用yarn cache dir查看缓存在哪里。

  

yarn cache dir

     

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

答案 1 :(得分:5)

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

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

GitHub Yarnpkg - "Incorrect integrity when fetching from the cache" #7584

答案 2 :(得分:3)

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

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

然后进行手动重建

答案 3 :(得分:1)

清理缓存并重新安装:

        $user_id = auth()->user()->id;
        $user = User::find($user_id);
        $thought_journal_entries = ThoughtJournalEntry::with('emotions')->where('user_id', $user_id)->orderBy('created_at', 'desc')->paginate(15);
        /*$thought_journal_entries = \DB::table('thought_journal_entries')->where('user_id', $user_id)->orderBy('created_at', 'desc')->paginate(15);*/

        return view('thoughtjournal.index')->with('thought_journal_entries', $thought_journal_entries);

答案 4 :(得分:1)

在安装软件包之前,您需要运行以下两个命令:

  • yarn config set unsafe-disable-integrity-migration false
  • yarn cache clean

答案 5 :(得分:0)

试图升级纱线,它解决了我的问题。可能是由于兼容性问题

yarn policies set-version

将下载最新的稳定版本

参考文献:yarn docs https://yarnpkg.com/lang/en/docs/cli/policies/#toc-policies-set-version