Home » Nodejs » Install electron on node for windows hangs

Install electron on node for windows hangs

Posted by: admin December 21, 2017 Leave a comment

Questions:

I am following the quick installtion guide on electron :http://electron.atom.io/

Script:

Clone the Quick Start repository

git clone https://github.com/electron/electron-quick-start

Go into the repository

cd electron-quick-start

Install the dependencies and run

npm install && npm start

The installation is stuck at

Node Install.js – this command is executed with npm install && npm start.

Is there a way i could find out what node install.js is doing in the backend to workout why it’s stuck?

Answers:

Checking out the electron/install.js file, it does download some flies and install it actually. So based on your bandwidth it may take some time.

// downloads if not cached
download({
  version: version,
  platform: process.env.npm_config_platform,
  arch: process.env.npm_config_arch,
  strictSSL: process.env.npm_config_strict_ssl === 'true',
  quiet: ['info', 'verbose', 'silly', 'http'].indexOf(process.env.npm_config_loglevel) === -1
}, extractFile)

// unzips and makes path.txt point at the correct executable
function extractFile (err, zipPath) {
  if (err) return onerror(err)
  fs.writeFile(path.join(__dirname, 'path.txt'), paths[platform], function (err) {
    if (err) return onerror(err)
    extract(zipPath, {dir: path.join(__dirname, 'dist')}, function (err) {
      if (err) return onerror(err)
    })
  })
}

Questions:
Answers:

with --verbose it makes it much more obvious if you’re somehow interrupting the electron module download during node_modules install
this will help to correct this by observing the download and installation process with:

npm install electron -g --verbose

With this command you will install global Electron. You can not cancel until the download process is complete. Delete the folder node_modules and reinstall.

Questions:
Answers:

Give it time, it will complete. You would not see a progress but it is executing in the backend.

Questions:
Answers:

I had a similar issue because of slow download rate.
As suggested by other answers try running npm install --verbose to see what is hanging. In my case, it was downloading the electron package at 20kb/s speed!.
enter image description here
With a little bit of investigation, I could find that electron is delegating the download task to electron-download package(https://www.npmjs.com/package/electron-download).

In the electron-download documentation, there are few ways to set the location/mirror where electron package could be downloaded.

Instead of setting up a local mirror as explained in the documentation, I manually downloaded the package from China mirror(https://npm.taobao.org/mirrors/electron/1.6.12/). I could get the package under 5 min. Then copied both package and SHASUMS256.txt to %USERPROFILE%\.electron folder.

Rerun the npm install --verbose and it was no longer hanging.

Questions:
Answers:

I was getting the same issue on a Windows 10 machine

  • Delete the %appdata%/npm/node_modules folder
  • Run command prompt in administrator mode.

The installation succeeded when I did these steps. Hope it helps someone else too

Questions:
Answers:

Wait until it finishes it’s background works while it seems hang but not. I also faced this problem and realized its background work was running by checking download speed of my modem manager. See the following image that DL speed is near 2mbps.

enter image description here