前言根据公司业务需求,使用 electron 开发桌面 BrowserWindow 应用。参考 API:Electron 文档安装与配置安装工具node(LTS版)git 命令行工具搭建项目初始化:$ npm init安装 electron:$ npm install electron –save-dev软件打包安装打包工具:$ npm install –save-dev electron-packager打包基本命令:electron-packager {location} {name} {platform} {architecture} {version} {options}location:项目所在路径name of project:打包的项目名字platform:确定了你要构建哪个平台的应用(Windows、Mac 还是 Linux)architecture:决定了使用 x86 还是 x64 还是两个架构都用version:electron 的版本options:可选选项在 package.json 中添加配置项:“packager”: “electron-packager ./ writ win x86 –app–version=2.0.6 –overwrite –icon=./favicon.ico"执行:$ npm run-script packager环境依赖.netframework 4.5.1python2.7Visual C++ Build Tools一键安装:$ npm install –global –production windows-build-tools环境设置:$ npm config set msvs_version 2015若出现 vc2015 安装失败情况,请自行安装 SP1windows6.1-KB976932 补丁插件依赖node-gyp Node 编写的跨平台命令行工具,用于编译 Node.js 的原生插件模块$ npm install -g node-gypffi 用以调用动态库的 Node.js 插件$ npm install ffi –savebuffer 提供与 Node.js 的 Buffer 完全相同的缓冲区插件$ npm install buffer –saveiconv-lite 用于在 Node.js 当中处理在各种操作系统出现的各种奇特编码,该模块不提供读写文件的操作,只提供文件编码转换的功能$ npm install iconv-lite –saveelectron-rebuild 用以重编译适合 electron 的模块$ npm install electron-rebuild –save-dev$ ./node_modules/.bin/electron-rebuild ./node_modules/ffi 占坑