一、切换源
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.orgnrm add taobao https://registry.npm.taobao.org
4、使用淘宝源
nrm use taobao
5、查看npm源地址:
nrm ls
其中*号是当前npm使用的源地址,可以使用nrm use xx命令切换npm的下载源
二、其他
1、electron 安装/打包慢、报错:
下面是我打包时候需要下载electron版本
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