《国内使用npm安装模块慢的解决方法》

1,171 阅读1分钟

参考:www.cnblogs.com/bonelee/p/9…

使用npm可以很方便的安装各种Node模块,但是npm默认连接的镜像库在国外,致使我们安装模块时很慢,甚至出现卡死现象。

官方镜像

registry.npmjs.org/

淘宝镜像

这是一个完整 npmjs.org 镜像,你可以用此代替官方版本(只读),同步频率目前为 10分钟 一次以保证尽量与官方服务同步。
网站地址:npm.taobao.org/

切换到淘宝镜像

1. 临时使用

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

2. 永久使用

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

3. 验证配置

npm config get registry

使用cnpm工具

1. 安装

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

2. 使用

cnpm install xxx