1. Use npm run example
1.1 Clone repository
git clone https://github.com/electron/electron-quick-start
1.2 Go into the repository
cd electron-quick-start
1.3 Install dependencies
PS:为了加快下载依赖模块的速度,通过修改镜像源
ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/ npm install
或者是
npm install --registry=https://registry.npm.taobao.org
1.4 Run the app
npm start
2. Use yarn create a electron program
2.1 Create a program folder
md electron-yarn-cz
进入项目文件夹
cd electron-yarn-cz
2.2 Create a program config file
yarn init
2.3 Instal electron environment
yarn add electron --dev --registry=https://registry.npm.taobao.org
2.4 Add main.js and index.html
2.5 Edit package.json file
"main": "main.js",
"scripts": {
"start": "electron ."
}
3. 打包项目
_推荐devtron 和 electron-builder 2个开发工具,配置简单,功能强大
3.1 添加打包模块
yarn add electron-builder --dev
3.2 在package.js中添加命令
"scripts": {
"start": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
}