Install electron on node for windows hangs
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.
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!.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.
Checking out the electron/install.js file, it does download some files and installs them actually. So based on your bandwidth it may take some time.
// downloads if not cacheddownload({ 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 executablefunction 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) }) })}