我的 .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
※ 设置Electron和Python的镜像地址
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