npm 切换 registry 可临时或永久设置:临时用 --registry 参数,永久执行 npm config set registry https://registry.npmmirror.com,淘宝源已迁移至 npmmirror.com,旧地址失效。

直接用 npm 命令切换 registry 就行,不需要改配置文件,操作简单、见效快。
临时使用淘宝源(单次命令)
在安装包时加 --registry 参数,只对当前命令生效:
npm install axios --registry https://registry.npmmirror.com永久设置为淘宝源(推荐)
执行一条命令,把 npm 默认源永久换成淘宝镜像(现为 npmmirror.com,原 taobao.org 已停用):
npm config set registry https://registry.npmmirror.com验证是否生效:
npm config get registry正常会输出:
https://registry.npmmirror.com
换回官方源(需要时可逆)
如果后续想切回 npm 官方源:
npm config set registry https://registry.npmjs.org注意几个细节
- 淘宝源域名已从 https://registry.npm.taobao.org 迁移至 https://registry.npmmirror.com,旧地址可能失效
- 全局配置优先级高于项目内 .npmrc,如项目根目录有 .npmrc 文件,可能覆盖全局设置
- 企业或内网环境若启用了私有 registry,需确认是否允许代理外部镜像
Java免费学习笔记:立即使用
解锁 Java 大师之旅:从入门到精通的终极指南











