NPM 国内加速,修改镜像源

为什么慢

执行 npm 各种命令的时候,默认是去 npm 官方镜像源获取需要安装的具体软件信息

以下命令查看当前使用的镜像源

npm config get registry

默认源地址在国外,从国内访问的速度肯定比较慢

如何修改镜像源

阿里旗下维护着一个完整的 npm 镜像源 registry.npmmirror.com

1. 临时修改

npm install 软件名 --registry https://registry.npmmirror.com

2. 全局修改

npm config set registry https://registry.npmmirror.com

3. 使用第三方软件快速修改、切换 npm 镜像源

nrm NPM registry manager
nrm 不仅可以快速切换镜像源,还可以测试自己网络访问不同源的速度

安装 nrm
npm install -g nrm
列出当前可用的所有镜像源
nrm ls

    npm -----  https://registry.npmjs.org/
    yarn --------- https://registry.yarnpkg.com/
    tencent ------ https://mirrors.cloud.tencent.com/npm/
    cnpm ----  http://r.cnpmjs.org/
    taobao --  https://registry.npmmirror.com/
    npmMirror ---- https://skimdb.npmjs.com/registry/
使用淘宝镜像源
nrm use taobao
测试访问速度
nrm test taobao

更多用法查看 nrm GitHub

本作品采用《CC 协议》,转载必须注明作者和本文链接
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
讨论数量: 2

yrm 镜像源更多一些

4年前 评论

可以根据源 @scope 设置代理。

 npm config set @your_company:registry http://your_company.com
3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!