npm默认镜像为:https://registry.npmjs.org/,使用以下方法更换镜像:
1、临时使用:
npm --registry https://registry.npm.taobao.org install '包名'
2、一直使用:
镜像搜索地址:http://npm.taobao.org/
打开cmd命令行,运行:
npm config set registry https://registry.npm.taobao.org
运行:
npm config ls
查找以下内容即可
registry = "https://registry.npm.taobao.org/"
仅查看仓库信息:
npm config get registry
说明更换成功,
再次使用 npm 即可。
3、切换为cnpm方法:
npm install -g cnpm --registry=https://registry.npm.taobao.org
使用:
cnpm install '包名'