优秀的编程知识分享平台

网站首页 > 技术文章 正文

npm如何管理和切换镜像 npm切换镜像地址

nanyue 2024-12-30 05:59:42 技术文章 3 ℃

npm 如何管理和切换镜像

方法一:

查看当前镜像源

> # npm get registry

https://registry.npmjs.org/

切换为淘宝镜像

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

切换回原镜像

> # npm config set registry https://registry.npmjs.org

使用 npmmirror 镜像

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

> # npm config list

......

registry = "https://registry.npmmirror.com/"

......

或者

> # npm install -g cnpm --registry=https://registry.npmmirror.com

注意: 原淘宝 npm 域名即将停止解析(https://registry.npm.taobao.org), 启用新的镜像(https://registry.npmmirror.com)

参考资料:

https://npmmirror.com/

方法二:

安装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 --------- https://r.cnpmjs.org/

taobao ------- https://registry.npmmirror.com/

npmMirror ---- https://skimdb.npmjs.com/registry/

> # nrm use taobao

> # npm config list

......

registry = "https://registry.npmmirror.com/"

......

最近发表
标签列表