1、安装nodejs(会自动安装npm)

2、桌面新建文件夹    your-app  (下面目录结构)

your-app/
├── package.json
├── main.js
└── index.html

3、package.json

{  "name"    : "your-app",
"version" : "0.1.0",
"main" : "main.js"
}

 4、index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
We are using node <script>document.write(process.versions.node)</script>,
Chrome <script>document.write(process.versions.chrome)</script>,
and Electron <script>document.write(process.versions.electron)</script>.
</body>
</html>

5、main.js

const {app, BrowserWindow} = require('electron')
const path = require('path')
const url = require('url') // Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let win function createWindow () {
// Create the browser window.
win = new BrowserWindow({width: 800, height: 600}) // and load the index.html of the app.
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
})) // Open the DevTools.
win.webContents.openDevTools() // Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null
})
} // This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow) // Quit when all windows are closed.
app.on('window-all-closed', () => {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
}) app.on('activate', () => {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (win === null) {
createWindow()
}
}) // In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.

6、安装electron (下面的命令意思:临时使用淘宝镜像 全局安装electron)

  执行命令 :  

npm --registry=https://registry.npm.taobao.org install -g electron

7、electron使用淘宝镜像  

set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/

  

----------------------------------------------------以上全部是 直接cmd 进命令行 执行命令---------------------------------------------------

8、发布exe

 cd 进项目根路径执行

npm install --save-dev electron-packager

 安装完成 会在package.json文件中多出一条electron-package的版本号配置信息

{
"name": "your-app",
"version": "0.1.0",
"main": "main.js",
"devDependencies": {
"electron-packager": "^8.5.2" //版本号配置信息
}
}

  

9、cd 进项目根路径( your-app--项目名称, electron-version版本号详见官网)

  执行打包命令 :

 electron-packager ./ your-app --all -all --electron-version=1.6.1

10、安装asar  (全局安装asar)

npm install asar -g

 11、

  cd 进 your-app\your-app-win32-x64\resources

  执行命令:

 asar pack your-app app.asar  

完成后就可以吧resources下的源代码删掉了

 

electron 新手教程 打包 exe的更多相关文章

  1. Electron入门应用打包exe(windows)

    最近在学习nodejs,得知Electron是通过将Chromium和Node.js合并到同一个运行时环境中,用HTML,CSS和JavaScript来构建跨平台桌面应用程序的一门技术.对于之前一直从 ...

  2. 给新手的最简单electron使用教程

    我花了两个月闲暇翻译完了文档,大概是目前最完整最实时的中文文档了,有需要可以去看看学学:github传送门,大多数的需求阅读文档即可解决,实际上,翻译文档正是我入门一项未知事物时的最简单常用的法子. ...

  3. win7下nsis打包exe安装程序教程

    下载软件包: NSIS中文版 :https://pan.baidu.com/s/1mitSQU0 装好之后会出现两个软件:Nullsoft Install System 和 VNISEdit 编译环境 ...

  4. Android基础新手教程——1.10 反编译APK获代替码&amp;资源

    Android基础新手教程--1.10 反编译APK获代替码&资源 标签(空格分隔): Android基础新手教程 本节引言: "反编译Apk".看上去好像好像非常高端的样 ...

  5. [新手教程]windows 2003 php环境搭建详细教程(转)

    对于windows服务器的php环境配置一直是是新人朋友的难题,也难倒了很多高手.这里分享一个新手教程,给那些建站新人使用.本教程来自朋友吴文辉的博客,欢迎大家有时间可以访问他的博客:吴文辉博客htt ...

  6. Android基础新手教程——1.2.1 使用Eclipse + ADT + SDK开发Android APP

    Android基础新手教程--1.2.1 使用Eclipse + ADT + SDK开发Android APP 标签(空格分隔): Android基础新手教程 1.前言 这里我们有两条路能够选,直接使 ...

  7. Android基础新手教程——1.2 开发环境搭建

    Android基础新手教程--1.2 开发环境搭建 标签: Android基础新手教程 如今主流的Android开发环境有: ①Eclipse + ADT + SDK ②Android Studio ...

  8. electron安装+运行+打包成桌面应用+打包成安装文件+开机自启动

    1.初始化node项目,生成package.json文件 npm init 2.安装electron,并保存为开发依赖项 npm install electron -D 3.根目录下新建index.j ...

  9. GitHub 新手教程 四,Git GUI 新手教程(1),OpenSSH Public Key

    1,从开始菜单 启动 Git GUI,或者运行: D:\soft\Git\cmd\git-gui.exe(D:\soft\Git 为您的 GitHub 安装文件夹) 2,获取 SSH 密钥: 3,点击 ...

随机推荐

  1. ZBrush中移动笔刷介绍

    移动笔刷是ZBrush®笔刷中举足轻重的一项,利用移动笔刷可以实现移动顶点的功能,还能改变模型的某一个点和某一位置.本文内容向大家介绍ZBrush®中移动笔刷以便大家熟悉它的用法和特性. 移动笔刷 可 ...

  2. div纵向居中的方法(转载)

    方法一这个方法把一些 div 的显示方式设置为表格,因此我们可以使用表格的 vertical-align property 属性. <div id="wrapper"> ...

  3. (3)pyspark----dataframe观察

    1.读取: sparkDF = spark.read.csv(path) sparkDF = spark.read.text(path) 2.打印: sparkDF.show()[这是pandas中没 ...

  4. ajax常用知识

     同源地址:任意两个地址中的协议,域名,端口相同,称为同源地址 同源策略:  是浏览器的一种基本安全策略                       不允许对非同源地址进行请求(ajax)       ...

  5. 启用Maven的代理访问

    1. Maven配置文件 找到文件 {M2_HOME}/conf/settings.xml, 并把你的代理服务器信息配置写入.注:{M2_HOME} => D:\software\yiibai. ...

  6. 【codeforces 508E】Artur and Brackets

    [题目链接]:http://codeforces.com/problemset/problem/508/E [题意] 让你构造一个括号字符串; 使得每个从左往右数第i个左括号在这个括号序列中与之匹配的 ...

  7. dubbo Failed to check the status of the service com.user.service.UserService. No provider available for the service

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'u ...

  8. NYIST 489 哭泣天使

    哭泣天使时间限制:1000 ms | 内存限制:65535 KB难度:5 描述Doctor Who乘着Tardis带着Amy来到了一个星球,一开Tadis大门,发现这个星球上有个壮观的石像群,全是一些 ...

  9. 洛谷 P2298 Mzc和男家丁的游戏

    P2298 Mzc和男家丁的游戏 题目背景 mzc与djn的第二弹. 题目描述 mzc家很有钱(开玩笑),他家有n个男家丁(做过上一弹的都知道).他把她们召集在了一起,他们决定玩捉迷藏.现在mzc要来 ...

  10. Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型

    转自原文 Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型 播放mp4格式的时候提示 Html 播放 mp4格式视频提示 没有发现支持的视频格式和mime类型 原因是在IIS中 ...