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


参考:https://www.cnblogs.com/bonelee/p/9995550.html

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

官方镜像

https://registry.npmjs.org/

淘宝镜像

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM