首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

构建说明(Windows) | Build Instructions (Windows)

按照下面的指导在Windows上构建Electron。

先决条件

  • Windows 7 / Server 2008 R2或更高版本

如果您目前没有Windows安装,则dev.microsoftedge.com会提供可用于构建Electron的Timebombed版本的Windows。

Building Electron完全使用命令行脚本完成,无法使用Visual Studio完成。您可以使用任何编辑器开发Electron,但支持使用Visual Studio进行构建将在未来发布。

注意:尽管Visual Studio不用于构建,但它仍然是必需的,因为我们需要它提供的构建工具链。

获取代码

代码语言:javascript
复制
$ git clone https://github.com/electron/electron.git

引导

引导脚本将下载所有必要的构建依赖项并创建构建项目文件。请注意,我们正在使用ninja构建Electron,因此不会生成Visual Studio项目。

代码语言:javascript
复制
$ cd electron
$ python script\bootstrap.py -v

构建

构建Release和Debug目标:

代码语言:javascript
复制
$ python script\build.py

您也可以只构建Debug目标:

代码语言:javascript
复制
$ python script\build.py -c D

构建完成后,您可以electron.exeout\D(调试目标)下或out\R(释放目标)下找到。

32位版本

要为32位目标构建,需要--target_arch=ia32在运行引导脚本时通过:

代码语言:javascript
复制
$ python script\bootstrap.py -v --target_arch=ia32

其他构建步骤完全相同。

Visual Studio项目

要生成Visual Studio项目,您可以传递--msvs参数:

代码语言:javascript
复制
$ python script\bootstrap.py --msvs

清除

清理构建文件:

代码语言:javascript
复制
$ npm run clean

仅清理outdist目录:

代码语言:javascript
复制
$ npm run clean-build

注意:这两个clean命令都需要bootstrap在构建之前再次运行。

测试

请参阅构建系统概述:测试

故障排除

Command xxxx not found

如果遇到类似错误Command xxxx not found,您可以尝试使用VS2015 Command Prompt控制台执行构建脚本。

Fatal internal compiler error: C1001

确保安装了最新的VisualStudio更新。

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

如果在Cygwin下构建,您可能会看到bootstrap.py以下错误失败:

代码语言:javascript
复制
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

这是由于一起使用Cygwin Python和Win32 Node导致的错误引起的。解决方案是使用Win32 Python来执行引导脚本(假设你已经安装了Python C:\Python27):

代码语言:javascript
复制
$ /cygdrive/c/Python27/python.exe script/bootstrap.py

LNK1181: cannot open input file ‘kernel32.lib’

尝试重新安装32位Node.js.

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

只需制作该目录即可解决问题

代码语言:javascript
复制
$ mkdir ~\AppData\Roaming\npm

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

如果您使用Git Bash进行构建,则可能会出现此错误,您应该改用PowerShell或VS2015命令提示符。

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com