查看 npm 配置
npm config list
- 将 npm 源切换至淘宝源
npm config set registry https://registry.npm.taobao.org
- 通过 npm 全局安装 yarn(如果你已安装过可以不需要再做这一步)
npm install -g yarn
npm bin -g
所得的路径添加至 PATH 环境变量中。 查看 yarn 配置 yarn config list
- 将 yarn 源切换至淘宝源
yarn config set registry https://registry.npm.taobao.org
- 执行
yarn install
aliasyarn(一般情况下到这就结束已经可以install了)
请在你的执行命令之后添加 --no-bin-links
e.g. yarn install --no-bin-links
- 如果遇到错误 error: xxxx node-sass: Command failed 将 sass-binary-site 添加至 config 中
指定 node-sass 从 npm 的淘宝源中下载。yarn config set sass-binary-site https://npm.taobao.org/mirrors/node-sass npm config set sass-binary-site https://npm.taobao.org/mirrors/node-sass
- 如果遇到错误
ERROR Failed to compile with 2 errors 11:10:34 error in ./resources/assets/sass/app.scss
- 检查你使用的源是否更换,当然可以选择使用代理
- 检查 sass-binary-site 是否指定
- 执行
yarn install --force node-sass
npm 对应的是npm rebuild node-sass
我习惯直接yarn install --force
将整个重新进行构建
- 如果你使用 yarn 安装了 vue 这样的 cli 工具。然后无法执行命令。请将
yarn global bin
添加至 PATH 环境变量中。 - 如果遇到 cross-env 报错
npm i -g cross-env