npm i node-sass 报错&npm 镜像切换

npm install --save node-sass --registry=https://registry.npm.taobao.org --disturl=https://npm.taobao.org/dist --sass-binary-site=http://npm.taobao.org/mirrors/node-sass

 or

先改变本机的sass下载的数据源

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

 然后 安装 

npm i node-sass -S

npm更换成淘宝的源

npm config set registry https://registry.npm.taobao.org
– 配置后可通过下面方式来验证是否成功
npm config get registry

发布npm包的时候切换为原始url:npm config set registry  https://registry.npmjs.org

也可安装nrm【管理npm的数据源的工具】:npm i -g nrm

显示数据源list: nrm ls

  npm ---- https://registry.npmjs.org/
  cnpm --- http://r.cnpmjs.org/
* taobao - http://registry.npm.taobao.org/
  edunpm - http://registry.enpmjs.org/
  eu ----- http://registry.npmjs.eu/
  au ----- http://registry.npmjs.org.au/
  sl ----- http://npm.strongloop.com/
  nj ----- https://registry.nodejitsu.com/
  pt ----- http://registry.npmjs.pt/

切换npm数据源:nrm use taobao或者nrm use eu

----------------------- 使用yarn ------------------------------------------

yarn config get registry
# -> https://registry.yarnpkg.com

可以改成 taobao 的源:

yarn config set registry https://registry.npm.taobao.org
# -> yarn config v0.24.5
# -> success Set "registry" to "https://registry.npm.taobao.org".
# -> Done in 0.03s.
原文地址:https://www.cnblogs.com/ryans/p/7846562.html