目录
1. 背景
2. npm
2.1. 配置镜像源
2.2. 配置代理
3. yarn
3.1. 配置镜像源
3.2. 配置代理
1. 背景
换npm、yarn的镜像源,或配置npm、yarn的代理,都是为了解决 npm 依赖下载慢的问题。
2. npm
2.1. 配置镜像源
// 查看镜像源
npm config get registry
// 设置镜像源
npm config set registry http://registry.npm.taobao.org/
npm config set registry https://registry.npmjs.org/
npm install -g nrm // 安装
nrm ls // 查看已有的源
nrm use <registry> // 切换源
nrm add <registry> <url> // 添加源
nrm del <registry> // 删除源
nrm test [registry] // 测速
2.2. 配置代理
// 查看代理
npm config get proxy
npm config get https-proxy
// 设置代理
npm config set proxy http://127.0.0.1:8080
npm config set https-proxy http://127.0.0.1:8080
// 删除代理
npm config delete proxy
npm config delete https-proxy
3. yarn
3.1. 配置镜像源
// 查看镜像源
yarn config get registry
// 设置镜像源
yarn config set registry http://registry.npm.taobao.org/
yarn config set registry https://registry.npmjs.org/
3.2. 配置代理
// 查看代理
yarn config get proxy
yarn config get https-proxy
// 设置代理
yarn config set proxy http://127.0.0.1:8080
yarn config set https-proxy http://127.0.0.1:8080
// 删除代理
yarn config delete proxy
yarn config delete https-proxy
参考:
NPM registry manager(nrm): https://github.com/Pana/nrm npm Docs: https://docs.npmjs.com/cli/v6/using-npm/config#proxy https://docs.npmjs.com/cli/v6/using-npm/config#https-proxy
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有