将 npm/yarn 的源地址替换成国内镜像的源地址

我的 .npmrc

registry=https://registry.npmmirror.com/

canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas/
sass_binary_site=https://registry.npmmirror.com/-/binary/node-sass
nodejs_org_mirror=https://registry.npmmirror.com/-/binary/node/
electron_mirror=https://registry.npmmirror.com/-/binary/electron/
electron_builder_binaries_mirror=https://registry.npmmirror.com/-/binary/electron-builder-binaries/
chromedriver_cdnurl=https://registry.npmmirror.com/-/binary/chromedriver/

npm

查看当前地址

npm config get registry

修改源地址为淘宝 NPM 镜像

npm config set registry https://registry.npmmirror.com/

修改源地址为官方源 

npm config set registry https://registry.npmjs.org/

http://npm.taobao.org 和 http://registry.npm.taobao.org 将在 2022.06.30 号正式下线和停止 DNS 解析。

npm config set registry https://registry.npm.taobao.org/ 

yarn

查看当前地址

yarn config get registry

修改源地址为淘宝 NPM 镜像​​​​​​

yarn config set registry https://registry.npmmirror.com/

修改源地址为官方源 

yarn config set registry https://registry.yarnpkg.com

其他(华为开源镜像

NPM的配置文件为用户根目录下的:~/.npmrc(Windows路径为:C:\Users\<UserName>\.npmrc),您可以点击此处直接下载配置文件,或者运行如下命令设置:

npm config set registry https://repo.huaweicloud.com/repository/npm/
npm cache clean -f

华为开源镜像站同时也提供了工具类加速镜像,可以通过如下的命令设置加速地址:

※ 设置nodejs工具的镜像地址

npm config set disturl https://repo.huaweicloud.com/nodejs

※ 设置Node-Sass的镜像地址

npm config set sass_binary_site https://repo.huaweicloud.com/node-sass

※ 设置浏览器引擎驱动镜像地址,如果需要安装Selenium,请点击此处

npm config set phantomjs_cdnurl https://repo.huaweicloud.com/phantomjs
npm config set chromedriver_cdnurl https://repo.huaweicloud.com/chromedriver
npm config set operadriver_cdnurl https://repo.huaweicloud.com/operadriver

※ 设置ElectronPython的镜像地址

npm config set electron_mirror https://repo.huaweicloud.com/electron/
npm config set python_mirror https://repo.huaweicloud.com/python

参考:华为开源镜像(语言类-NPM

从源头构建安装

npm install --build-from-source

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱宇阳

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值