June 3, 2024

npm/pnpm/yarn切换/还原安装源

指令

查看源

1
2
3
4
5
6
# NPM
npm config get registry
# PNPM
pnpm config get registry
# YARN
yarn config get registry

临时使用某个源

1
2
3
4
5
6
# NPM
npm install package-name --registry=https://registry.npmmirror.com
# PNPM
pnpm add package-name --registry=https://registry.npmmirror.com
# YARN
yarn add package-name --registry=https://registry.npmmirror.com

持久使用

1
2
3
4
5
6
# NPM
npm config set registry https://registry.npmmirror.com
# PNPM
pnpm config set registry https://registry.npmmirror.com
# YARN
yarn config set registry https://registry.npmmirror.com

还原

1
2
3
4
5
6
# NPM
npm config set registry https://registry.npmjs.org
# PNPM
pnpm config set registry https://registry.npmjs.org
# YARN
yarn config set registry https://registry.yarnpkg.com


可用源

1
2
3
4
5
6
7
8
9
10
11
# NPM官方源
https://registry.npmjs.org

# 淘宝镜像源
https://registry.npmmirror.com

# 腾讯云镜像源
http://mirrors.cloud.tencent.com/npm/

# 清华大学开源镜像站
https://mirrors.tuna.tsinghua.edu.cn


Reference

About this Post

This post is written by Andy, licensed under CC BY-NC 4.0.

#NPM#PNPM#YARN