npm太慢,更换淘宝镜像

1.临时使用

npm --registry https://registry.npm.taobao.org install express

2.持久使用

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

配置后可通过下面方式来验证是否成功 npm config get registry 或 npm info express 3.通过cnpm使用

npm install -g cnpm --registry=https://registry.npm.taobao.org

使用 cnpm install express

4、npm修改或切换镜像地址 方法一:直接编辑npm配置文件 npm config edit

1416090-20180621111355013-1113191392.png
直接修改registry的地址:
sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org

方法二:用代码更改npm的配置文件 npm config set registry http://registry.npm.taobao.org

方法三:使用nrm管理registry地址

安装nrm

npm i -g nrm

查看镜像列表

nrm ls

切换镜像

nrm use taobao

在nrm添加自己的镜像地址

nrm add r_name r_url

删除

nrm del r_name

测试镜像的相应速度

nrm test r_name

Comments