当前位置:K88软件开发文章中心编程工具Electron → 文章内容

Electron 构建步骤 (Windows)

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-24 10:21:40

由 Loen 创建, 最后一次修改 2016-10-08 遵循下面的引导,在 Windows 上构建 Electron .前提Windows 7 / Server 2008 R2 or higherVisual Studio 2013 with Update 4 - download VS 2013 Community Edition for free.Python 2.7Node.jsGit如果你现在还没有安装 Windows , modern.ie 有一个 timebombed 版本的 Windows ,你可以用它来构建 Electron.构建 Electron 完全的依赖于命令行,并且不可通过 Visual Studio. 可以使用任何的编辑器来开发 Electron ,未来会支持 Visual Studio.注意: 虽然 Visual Studio 不是用来构建的,但是它仍然 必须的 ,因为我们需要它提供的构建工具栏.注意: Visual Studio 2015 不可用. 请确定使用 MSVS 2013.获取代码$ git clone https://github.com/electron/electron.gitBootstrappingbootstrap 脚本也是必要下载的构建依赖,来创建项目文件.注意我们使用的是 ninja 来构建 Electron,所以没有生成 Visual Studio 项目.$ cd electron$ python script\bootstrap.py -v构建创建 Release 、 Debug target:$ python script\build.py可以只创建 Debug target:$ python script\build.py -c D创建完毕, 可以在 out/D(debug target) 或 out\R (release target) 下面找到 electron.exe.64bit Build为了构建64位的 target,在运行 bootstrap 脚本的时候需要使用 --target_arch=x64 :$ python script\bootstrap.py -v --target_arch=x64其他构建步骤完全相同.Tests测试你的修改是否符合项目代码风格,使用:$ python script\cpplint.py测试有效性使用:$ python script\test.py在构建 debug 时为 Tests包含原生模块 (例如 runas) 将不会执行(详情 #2558), 但是它们在构建 release 会起效.运行 release 构建使用 :$ python script\test.py -R解决问题Command xxxx not found如果你遇到了一个错误,类似 Command xxxx not found, 可以尝试使用 VS2012 Command Prompt 控制台来执行构建脚本 .Fatal internal compiler error: C1001确保你已经安装了 Visual Studio 的最新安装包 .Assertion failed: ((handle))->activecnt >= 0如果在 Cygwin 下构建的,你可能会看到 bootstrap.py 失败并且附带下面错误 :Assertion failed: ((handle))->activecnt >= 0, file src\win\pipe.c, line 1430Traceback (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 esubprocess.CalledProcessError: Command '['npm.cmd', 'install']' returned non-zero exit status 3这是由同时使用 Cygwin Python 和 Win32 Node 造成的 bug.解决办法就是使用 Win32 Python 执行 bootstrap 脚本 (假定你已经在目录 C:\Python27 下安装了 Python):$ /cygdrive/c/Python27/python.exe script/bootstrap.pyLNK1181: cannot open input file 'kernel32.lib'重新安装 32位的 Node.js.Error: ENOENT, stat 'C:\Users\USERNAME\AppData\Roaming\npm'简单创建目录 应该可以解决问题:$ mkdir ~\AppData\Roaming\npmnode-gyp is not recognized as an internal or external command如果你使用 Git Bash 来构建,或许会遇到这个错误,可以使用 PowerShell 或 VS2012 Command Prompt 来代替 .

Electron 构建步骤 (Windows)