npm、pnpm、yarn镜像源设置

以下为 npm 镜像

npm 查询当前镜像

bash 复制代码
npm get registry

npm 设置为淘宝镜像

淘宝镜像源一(推荐)

bash 复制代码
npm config set registry https://registry.npmmirror.com/

淘宝镜像源二

bash 复制代码
npm config set registry http://registry.npm.taobao.org/

npm 设置为官方默认镜像

bash 复制代码
npm config set registry https://registry.npmjs.org/

以下为 pnpm 镜像

npm 安装 pnpm

bash 复制代码
npm install -g pnpm

查看是否安装成功

bash 复制代码
pnpm -v

查看当前镜像

bash 复制代码
pnpm config get registry

设为淘宝镜像

淘宝镜像源一(推荐)

bash 复制代码
pnpm config set registry https://registry.npmmirror.com/

淘宝镜像源二

bash 复制代码
pnpm config set registry http://registry.npm.taobao.org/

设为官方默认镜像

bash 复制代码
pnpm config set registry https://registry.npmjs.org

以下为 yarn 镜像

npm 安装 yarn

bash 复制代码
npm install -g yarn

npm 卸载 yarn

bash 复制代码
npm uninstall -g yarn

查看是否安装/卸载成功

bash 复制代码
yarn -v

查询当前镜像

bash 复制代码
yarn config get registry

设置为淘宝镜像

淘宝镜像源一(推荐)

bash 复制代码
yarn config set registry https://registry.npmmirror.com/

淘宝镜像源二

bash 复制代码
yarn config set registry http://registry.npm.taobao.org/

设置为官方默认镜像

bash 复制代码
yarn config set registry https://registry.yarnpkg.com/

错误提示

① 有时候会遇到以下报错,可能是因为镜像问题(官方默认镜像有时访问不了)

info There appears to be trouble with your network connection.

Retrying...

② 当 npm install 时遇到报错 ERESOLVE unable to resolve dependency tree 的问题

方案一:版本降级(原版本是 16.20.1,降级为 14.21.3)

方案二:npm install -f 带上 --force 参数(简写 -f)告诉 npm 强制安装

相关推荐
卷福同学41 分钟前
AI编程出海第二步:验证关键词能否做站
前端·人工智能·后端
先吃饱再说1 小时前
编写一个颜色选择器之后,我理解了 React 工程化的三层架构
react.js·前端框架·前端工程化
先吃饱再说1 小时前
别说你懂 useEffect:从底层机制到生命周期管理,这篇全讲透了
react.js·前端框架
赵庆明老师1 小时前
Vben精讲:21-详解web-antd:tsconfig.json
前端·json·vim
先吃饱再说1 小时前
从“传事件”到“只传值”:React + TypeScript 组件 Props 设计的两次进化
react.js·前端框架·前端工程化
wc881 小时前
微软EDGE浏览器功能学习
前端·学习·edge
破z晓1 小时前
javascript 导出excel表
开发语言·javascript·excel
Csvn2 小时前
🎯 原生 `<dialog>` 元素:终于可以扔掉一半的自定义弹窗组件了?
前端
Csvn2 小时前
🎨 CSS @layer:用「层叠优先级」终结样式打架的世纪难题
前端
小罗水2 小时前
第17章 后台管理端与演示支持
javascript·vue.js·ecmascript