npm/pnpm/yarn 切换源

npm/pnpm/yarn 切换源

  • 国内镜像
提供商搜索地址registry 地址
淘宝https://npmmirror.com/open in new windowhttps://registry.npmmirror.comopen in new window
腾讯云http://mirrors.cloud.tencent.com/npm/open in new window
华为云https://mirrors.huaweicloud.com/repository/npmopen in new window
浙江大学http://mirrors.zju.edu.cn/npm/open in new window
南京邮电https://mirrors.njupt.edu.cn/nexus/repository/npm/open in new window

npm

# 查看源
npm get registry
npm config get registry

# 临时修改
npm --registry https://registry.npmmirror.com install any-touch

# 永久修改
npm config set registry https://registry.npmmirror.com

# 还原
npm config set registry https://registry.npmjs.org

NRM

# 安装 nrm
npm install -g nrm

# 列出当前可用的所有镜像源
nrm ls

# 使用淘宝镜像源
nrm use taobao

# 测试访问速度
nrm test taobao

pnpm

# 查看源
pnpm get registry
pnpm config get registry

# 临时修改
pnpm --registry https://registry.npmmirror.com install any-touch

# 永久修改
pnpm config set registry https://registry.npmmirror.com

# 还原
pnpm config set registry https://registry.npmjs.org

yarn

# 查看源
yarn config get registry

# 临时修改
yarn add any-touch@latest --registry=https://registry.npmjs.org/

# 永久修改
yarn config set registry https://registry.npmmirror.com/

# 还原
yarn config set registry https://registry.yarnpkg.com

YRM

# 安装 yrm
npm install -g yrm

# 列出当前可用的所有镜像源
yrm ls

# 使用淘宝镜像源
yrm use taobao

# 测试访问速度
yrm test taobao

更换本地缓存


pnpm config set store-dir <new path> //将<new path> 替换为目标存储路径(非中文)

pnpm store path

Last Updated:
Contributors: 刘荣杰