Solve the problem that electron 8.0.0 is stuck in node install.js under Windows

Time:2020-2-13

Editor: vs Code

problem

NPM I electron-d is stuck in node install.js all the time. The search engine has found many solutions, such as modifying image source and modifying image source.npmrcDocument, modificationhostWait, it’s not applicable in electronic @ 8.0.0. The only solution that can be used is the fourth solution in the article, but it’s still too troublesome. So I rolled the source code of install.js in electronic @ 8.0.0 and found the following two methods

Scheme 1

  • When stuck in node install.jsctrl+cExit process
  • CD node_modules / Electronic & & code install.js (open install. JS)
  • The modification code is shown in the figure below, with code attached belowSolve the problem that electron 8.0.0 is stuck in node install.js under Windows
  • Finally, CD node_modules / Electronic & & node install.js (install electronic manually)
mirrorOptions:{
  mirror:'https://npm.taobao.org/mirrors/electron/',
  customDir:'8.0.0',
  // customFilename:'electron-8.0.0-win32-x64.zip'
}

This scheme is also mentioned in other articles, but the version is different and the modified parameters are different

Option two

#Add / modify environment variables
#cmd
set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
set ELECTRON_CUSTOM_DIR=8.0.0
#powershell
$env:ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"
$env:ELECTRON_CUSTOM_DIR="8.0.0"
#Delete environment variable
#cmd
set ELECTRON_MIRRO=
set ELECTRON_CUSTOM_DIR=
#powershell
del env:ELECTRON_MIRROR
del env:ELECTRON_CUSTOM_DIR
  • Do not want to tap the command line: right click (this computer) – > properties – > advanced system settings – > environment variables… (permanent, but the command-line tools in vscode may not get it)
  • Then install it directlynpm i electron -D

Option three

Add the following settings in setting.json of vscode

"terminal.integrated.env.windows":{
    "ELECTRON_MIRROR":"https://npm.taobao.org/mirrors/electron/",
    "ELECTRON_CUSTOM_DIR":"8.0.0"
}

For friends who use vscode, it is recommended to use scheme 3~

(scheme II and III are applicable toelectron-packagerPackage stuck)
Solve the problem that electron 8.0.0 is stuck in node install.js under Windows