构建步骤 (Windows)
- Windows 10 / Server 2012 R2 或更高版本
- Visual Studio 2017 15.7.2 或更高版本 - 免费下载 VS 2019 社区版
- 请参阅,以了解有哪些Visual Studio 组件需要安装等详细信息。
- Python 2.7.10 或更高版本
- 与下面
depot_tools
的安装说明不同,你必须安装 2.7.10 以上版本的 Python(支持 TLS 1.2)。 为此,应确保 PATH 中 Python 的安装目录在depot_tools
之前。 目前 仍捆绑 Python 2.7.6,这将导致gclient
命令失效(见 - Python for Windows (pywin32) 扩展对于构建流程也是必需的。
- 与下面
- Git
- Debugging Tools for Windows of Windows SDK 10.0.15063.468 if you plan on creating a full distribution since
symstore.exe
is used for creating a symbol store from.pdb
files.- 还必须安装 SDK 调试工具。 如果已安装了 Windows 10 SDK 通过 Visual Studio 安装程序,然后可以用以下方式安装它们:
控制面板
→程序
→程序和功能
→选择“Windows 软件开发工具包”→更改
→→选中“Windows 调试工具”→更改
。 或者,您可以下载独立的 SDK 安装程序,并且使用它安装调试工具。
- 还必须安装 SDK 调试工具。 如果已安装了 Windows 10 SDK 通过 Visual Studio 安装程序,然后可以用以下方式安装它们:
如果您当前没有安装 Windows, 上有时间限制的 Windows 版本,你可以用来构建 Electron。
构建 Electron 完全由命令行脚本完成,无法通过 Visual Studio 完成。 您可以使用任何编辑器开发 Electron,但将来将会使用 Visual Studio 构建支持。
Note: Even though Visual Studio is not used for building, it’s still required because we need the build toolchains it provides.
其他构建步骤完全一样。
要生成 Visual Studio 项目,可以传递 --ide=vs2017
参数 给 gn gen
:
如果你遇到了一个错误,类似 Command xxxx not found
, 可以尝试使用 VS2015 Command Prompt
控制台来执行构建脚本.
Fatal internal compiler error: C1001
确保你已经安装了 Visual Studio 的最新安装包.
LNK1181: cannot open input file ‘kernel32.lib’
创建那个目录 :
node-gyp is not recognized as an internal or external command
如果你使用 Git Bash 来构建,或许会遇到这个错误,可以使用 PowerShell 或 VS2015 Command Prompt 来代替.
无法在“…”处创建目录:文件名太长
node.js 有一些 极长的路径名,默认情况下,windows 上的 git 不能正确处理长路径名(即使 windows 支持它们)。 这应该可以修复它:
This can happen during build, when Debugging Tools for Windows has been installed with Windows Driver Kit. Uninstall Windows Driver Kit and install Debugging Tools with steps described above.
导入错误:没有名为 win32file 的模块
构建脚本挂起, 直到某个按键按下才有响应
这个bug 是 Windows 命令提示符的一个”功能” It happens when clicking inside the prompt window with enabled and is intended to allow selecting and copying output text easily. 由于每次意外点击都会暂停构建过程,您可能需要在命令的属性中禁用此 功能。