Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Electron Build Steps (Windows)


May 25, 2021 Electron


Table of contents


Follow the instructions below to build Electron on Windows .

Premise

If you haven't installed Windows modern.ie, you can use it to build Electron because you have a timebombed version of Windows.

Building Electron is completely dependent on the command line and cannot be passed through Visual Studio. You can use any editor to develop Electron, which will support Visual Studio in the future.

Note: Although Visual Studio is not intended for construction, it is still necessary because we need the build toolbar it provides.

Note: Visual Studio 2015 is not available. Make sure you use MSVS 2013 .

Get the code

$ git clone https://github.com/electron/electron.git

Bootstrapping

Bootstrap scripts are also necessary to download build dependencies to create project files. Note that we're ninja to build Electron, so we didn't build the Visual Studio project.

$ cd electron
$ python script\bootstrap.py -v

Build

Create Release Debug Target:

$ python script\build.py

You can create Debug target:

$ python script\build.py -c D

Once you're done, you can find the electron image below out/D (debug target) or out\R electron.exe .

64bit Build

In order to build a 64-bit target, you need to run the bootstrap script --target_arch=x64 :

$ python script\bootstrap.py -v --target_arch=x64

The other build steps are exactly the same.

Tests

Test your modifications to match the project code style, using:

$ python script\cpplint.py

Test effectiveness use:

$ python script\test.py

Native modules (such as runas) that contain native modules (such as runas will not be executed when debug is built (details #2558), but they will work when building release.

Run release build using:

$ python script\test.py -R

Fix the problem

Command xxxx not found

If you encounter an error similar to Command xxxx not found you can try VS2012 Command Prompt to execute the build script .

Fatal internal compiler error: C1001

Make sure you have the latest installation package for Visual Studio installed.

Assertion failed: ((handle))->activecnt >= 0

If you build under Cygwin, you may see bootstrap.py with the following error:

Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430

Traceback (most recent call last):
  File "script/bootstrap.py", line 87, in <module>
    sys.exit(main())
  File "script/bootstrap.py", line 22, in main
    update_node_modules('.')
  File "script/bootstrap.py", line 56, in update_node_modules
    execute([NPM, 'install'])
  File "/home/zcbenz/codes/raven/script/lib/util.py", line 118, in execute
    raise e
subprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3

This is a bug caused by using both Cygwin Python and Win32 Node. The solution is to execute bootstrap scripts using Win32 Python (assuming you've installed Python under directory C:\Python27

$ /cygdrive/c/Python27/python.exe script/bootstrap.py

LNK1181: cannot open input file 'kernel32.lib'

Reinstall the 32-bit Node .js.

Error: ENOENT, stat 'C:\Users\USERNAME\AppData\Roaming\npm'

Simply creating a directory should solve the problem :

$ mkdir ~\AppData\Roaming\npm

node-gyp is not recognized as an internal or external command

If you're using Git Bash to build, you might encounter this error, and you can use PowerShell or VS2012 Command Prompt instead of .