问题:.yarn-metadata.json: Unexpected end of JSON input
工具: react + umi + vsCode + yarn
某天拉了个新项目,然后安装依赖,结果到了第三步就会报错;

1.png
开始以为是babel出错了,重新
yarn global add babel, 结果还是不行;然后换了yarn的源,也不行;
yarn config get registry 查看当前源yarn config set registry https://registry.npm.taobao.org 切换为淘宝源yarn config set registry https://registry.yarnpkg.com 或者切换为自带的
最后百度,随眼缘选了个关键词 yarn-metadata

image.png
结果还真找到了线索:https://github.com/yarnpkg/yarn/issues/660

image.png
非常相似的问题:先清yarn 的缓存
yarn cache clean, 然后再重新 yarn即可,问题完美解决。