一、切换源

1、安装淘宝镜像cnpm(如果之前安装过跳过)

npm install -g cnpm --registry=https://registry.npm.taobao.org

2、安装nrm,切换源地址(下载依赖包的地址)

npm install -g nrm

3、nrm添加源:

nrm add npm http://registry.npmjs.org
nrm add taobao https://registry.npm.taobao.org

4、使用淘宝源

nrm use taobao

5、查看npm源地址:

nrm ls
其中*号是当前npm使用的源地址,可以使用nrm use xx命令切换npm的下载源

NPM国内下载慢以及报错的解决方案

二、其他

1、electron 安装/打包慢、报错:

下面是我打包时候需要下载electron版本
NPM国内下载慢以及报错的解决方案

npm config set ELECTRON_MIRROR https://npm.taobao.org/mirrors/electron/

npm config set ELECTRON_CUSTOM_DIR=版本号

版本号:像上面我打包的时候需要下载electron-v9.1.1-win32-x64的文件的,那么版本号就是9.1.1

参考:
1、https://www.jianshu.com/p/94d084ce6834
2、https://www.jianshu.com/p/520934cea5ee

相关文章:

  • 2022-01-21
  • 2022-12-23
  • 2021-07-19
  • 2021-11-08
  • 2021-09-28
  • 2021-08-11
  • 2022-12-23
猜你喜欢
  • 2022-03-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案