Electron installation Errors

Electron is a framework for building desktop applications using JavaScript, HTML and CSS.

When you are following the tutorial on the official website, you might have problems when you try to install the electron package:

1
npm install electron --save-dev

You might come across error messages such as Electron RequestError: connect ETIMEDOUT 20.205.243.166:443. This problem is so common that many developers are asking the same question all the time, even the official document has given their solution.

To summarise, if you are a developer who is living in China, you can simply create a .npmrc in your project root folder, then add this line into the file:

1
electron_mirror=https://npmmirror.com/mirrors/electron/

Save and close the file. Try the command above again, you should be able to install Electron now.

Alternatively, you can also set NPM config settings by running:

1
2
3
4
5
6
# yarn
yarn config set electron_mirror https://npmmirror.com/mirrors/electron/

# npm

npm config set ELECTRON_MIRROR https://npmmirror.com/mirrors/electron/