使用纱线添加cors但出现错误

Used yarn to add cors but there is an error

我遇到了这个问题:

error An unexpected error occurred: "/home/vagrant/.cache/yarn/v1/npm-cors-2.8.4-2bd381f2eb201020105cd50ea59da63090694686/.yarn-metadata.json: Unexpected end of JSON input".

注意几点:

  1. 在安装 cors (yarn add cors) 期间,我的笔记本电脑没电了。

  2. 节点模块中有 cors 文件,但未在 package.json 中列出。

  3. 我最近从 npm 切换到 yarn 并在 vagrant VM 中运行。

  4. 试图从节点模块中删除文件,但 id 没有任何区别

yarn remove cors 给出了这个错误:

error This module isn't specified in a manifest.

看来你的纱线缓存坏了。执行 yarn cache clean 并重试模块安装。