electron安装之前需要安装node.js,本文主要通过npm的方式安装
替换淘宝npm
由于npm的服务器在国外,速度比较慢,而且有时会出现一些下载不成功出现的错误,这里选用淘宝的npm,替换命令如下:
npm install -g cnpm --registry=https://registry.npm.taobao.org
通过注册cnpm实现替换,以后安装就可以通过cnpm进行,而不用npm
安装electron
cnpm install -g electron
安装electron的打包工具
cnpm install -g electron-packager
测试electron
这里通过github一个quickapp进行测试electron,你可以在github上搜索electron-quick-start项目,作为你的第一个demo,使用方法如下:
# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start
此时你就会看到一个hello world的窗口,可以使用html/css/js方式构建桌面应用,想想都觉得是一件很酷的事情。