yarn安装依赖错误

507 阅读1分钟

yarn安装依赖遇到error An unexpected error occurred: "registry.yarnpkg.com/react: con...这种错误,这是网络超时,配置淘宝镜像即可。

yarn 设置为 淘宝源

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

npm 设置为 淘宝源

npm config set registry https://registry.npm.taobao.org
npm config set disturl https://npm.taobao.org/dist

项目中如果用的是 sass,需要下载 node-sass,这个依赖包下载是相当的慢,可以单独设置源地址

yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass
npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

最后删除 node_modules,重新下载就行了