npm install初始化electron项目时下载太慢的解决办法

  • 卡在 Downloading electron-v22.0.0-win32-x64.zip
#下载对应的版本electron-v21.3.3-win32-x64.zip
https://registry.npmmirror.com/binary.html?path=electron/

mkdir node_modules/electron/dist #将刚下载的压缩包解压到dist文件夹中


vi  node_modules/electron/dist/path.txt 
electron.exe #win
#其它系统
Electron.app/Contents/MacOS/Electron #mac系统
electron  #linux系统

打包downloading太慢解决方案

在项目根目录下增加一个.npmrc文件

ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/
或者
electron_mirror=https://npm.taobao.org/mirrors/electron/
ELECTRON_BUILDER_BINARIES_MIRROR=http://npm.taobao.org/mirrors/electron-builder-binaries/