國內鏡像
常用的國內鏡像:
淘寶鏡像 https://registry.npmmirror.com
騰訊云鏡像?? https://mirrors.cloud.tencent.com/npm/
華為云鏡像?? https://repo.huaweicloud.com/repository/npm/
CNPM(阿里系) ?? https://r.cnpmjs.org/
清華大學鏡像?? https://mirrors.tuna.tsinghua.edu.cn/help/npm/
npm
# 查詢當前使用的鏡像源
npm get registry# 設置為淘寶鏡像源
npm config set registry https://registry.npmmirror.com/# 還原為官方鏡像源
npm config set registry https://registry.npmjs.org/
pnpm
# 查詢當前使用的鏡像源
pnpm get registry# 設置為淘寶鏡像源
pnpm config set registry https://registry.npmmirror.com/# 還原為官方鏡像源
pnpm config set registry https://registry.npmjs.org/
yarn
# 查詢當前使用的鏡像源
yarn config get registry# 設置為淘寶鏡像源
yarn config set registry https://registry.npmmirror.com/# 還原為官方鏡像源
yarn config set registry https://registry.yarnpkg.com/
臨時指定鏡像
npm --registry https://registry.npmjs.org/ install <package-name>
pnpm --registry https://registry.npmjs.org/ add <package-name>
yarn add <package-name> --registry=https://registry.yarnpkg.com/