npm/yarn/pnpm最新阿里镜像源配置

31,939 阅读1分钟

最近重装电脑了,需要重新配置node和npm,但是在网上找到的配置npm国内镜像源地址,大部分文章写的还是已经废弃的 https://registry.npm.taobao.org 这个地址,在此特别记录了一下最新阿里镜像源地址 https://registry.npmmirror.com 以及配置

整理了3个常用包管理工具的设置, 收藏起来, 用的时候复制粘贴.

npm

查看源

npm get registry

临时修改

npm --registry https://registry.npmmirror.com install axios

持久使用

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

还原

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

yarn

查看源

yarn config get registry

临时修改

yarn add axios --registry=https://registry.npmjs.org/

持久修改

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

pnpm

查看源

pnpm get registry 

临时修改

pnpm --registry https://registry.npmmirror.com install axios

持久使用

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

还原

pnpm config set registry https://registry.npmjs.org

一些问题说明

  1. 在配置阿里镜像源之后,可能有一些包的某个版本在安装的过程提示不存在,但是到 https://www.npmjs.com/ npm 官网查询又发现可能是存在的。出现这个问题可能就是因为这个包 阿里镜像源没有同步过来,这个时候就可以到 npmmirror 镜像站 这个镜像站手动同步一下