记一次使用Node.js electron打包网站的记录
具体步骤请参考:http://blog.csdn.net/a727911438/article/details/70834467
打包时出现了不少问题,逐一记录下来以供其他人参考。
package.json文件内容
{
"name": "appname",
"version": "0.1.0",
"main": "./main.js",
"scripts": {
"start": "electron ."
}
}
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: , height: }) // 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.
安装好打包神器后,在执行 electron-packager时出现“Unable to determine Electron version. Please specify an Electron version”错误:
要解决这一问题,只需在命令中指定Electron version,具体命令如下:
electron-packager . sound_machine --win --out a --arch=
x64 --version=0.1. --electron-version=1.6. --overwrite --ignore=node_modules
由于本地网络采用的是服务器代理上网模式,因此还需为npm指定代理地址,否则会出现“tunneling socket could not be established, statusCode=502”的错误。
设置npm代理的命令如下:
npm config set proxy=http://10.**.**.**:8080
再次执行 electron-packager打包命令,这次没有错误了,提示开始下载文件。下载完成后开始打包,提示打包成功:
至此,打包完成。
记一次使用Node.js electron打包网站的记录的更多相关文章
- Nodejs学习笔记(十五)--- Node.js + Koa2 构建网站简单示例
目录 前言 搭建项目及其它准备工作 创建数据库 创建Koa2项目 安装项目其它需要包 清除冗余文件并重新规划项目目录 配置文件 规划示例路由,并新建相关文件 实现数据访问和业务逻辑相关方法 编写mys ...
- [转]Nodejs学习笔记(十五)--- Node.js + Koa2 构建网站简单示例
本文转自:https://www.cnblogs.com/zhongweiv/p/nodejs_koa2_webapp.html 目录 前言 搭建项目及其它准备工作 创建数据库 创建Koa2项目 安装 ...
- Nodejs学习笔记(十五)—Node.js + Koa2 构建网站简单示例
前言 前面一有写到一篇Node.js+Express构建网站简单示例:http://www.cnblogs.com/zhongweiv/p/nodejs_express_webapp.html 这篇还 ...
- 个人项目WC.exe Node.js+electron实现
前言 实现语言:Javascript 编译工具:webstorm GitHub:https://github.com/NPjuan/WC.git 项目要求 wc.exe 是一个常见的工具,它能统计文本 ...
- Node.js JXcore 打包
Node.js 是一个开放源代码.跨平台的.用于服务器端和网络应用的运行环境. JXcore 是一个支持多线程的 Node.js 发行版本,基本不需要对你现有的代码做任何改动就可以直接线程安全地以多线 ...
- Node.JS 项目打包 JXCore
哈哈,又回来了 当你开发完成了Node.JS项目,你应该需要打包发行吧 好,JXCore就是干这个的啦! 嗯,可能你会这样来安装 1. curl http://jxcore.com/xil.sh | ...
- Node.js 项目打包
Node项目基于Electron打包 Electron打包打包后项目.exe程序包含在文件夹中,基于Electron打包的基础上直接打包成exe程序 参考一 参考二 需求的软件环境: NSIS 2.4 ...
- 记一次在node.js中使用crypto的createCipheriv方法进行加密时所遇到的坑
Node.js的crypto模块提供了一组包括对OpenSSL的哈希.HMAC.加密.解密.签名,以及验证等一整套功能的封装.具体的使用方法可以参考这篇文章中的描述:node.js_crypto模块. ...
- Nodejs学习笔记(六)--- Node.js + Express 构建网站预备知识
目录 前言 新建express项目并自定义路由规则 如何提取页面中的公共部分? 如何提交表单并接收参数? GET 方式 POST 方式 如何字符串加密? 如何使用session? 如何使用cookie ...
随机推荐
- 使用CEF的JSON解析功能
Cef提供了JSON解析功能,在cef_parser.h文件内有三个JSON相关的方法: CefParseJSON CefParseJSONAndReturnError CefWriteJSON 以最 ...
- HLJU 1223: 寻找区间和 (交替推进法)
1223: 寻找区间和 Time Limit: 3 Sec Memory Limit: 128 MB Submit: 13 Solved: 4 [Submit][Status][pid=1223& ...
- Swiper单页网站简单案例(全屏网页)
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...
- java并发编程的艺术——第一章总结
并发编程的挑战 1.1上下文切换 1.2死锁 1.3资源限制的挑战 1.4本章小结 1.1上下文切换 1.1.1多线程一定快吗 1.1.2测试上下文切换次数和时长 1.1.3如何减少上下文切换 1.1 ...
- Python的类(class)
python 3.6 官方文档 https://docs.python.org/3.6/index.html python 3.6 的类 https://docs.python.org/3.6/tu ...
- NanUI文档 - 使用网页来设计整个窗口
NanUI文档目录 NanUI简介 开始使用NanUI 打包并使用内嵌式的HTML/CSS/JS资源 使用网页来设计整个窗口 如何实现C#与Javascript相互掉用(待更新...) 如何处理Nan ...
- idea将maven项目打包成war包的方式,以及使用war包
打包WAR过程 首先对项目进行编译.然后执行以下步骤: 单击下图红色方框处 在IDEA右侧出现maven project选项 单击maven project选项,出现Spring MVC Basi ...
- 【ANT】时间戳
属性 说明 举例 DSTAMP 设置为当前日期,默认格式:yyyymmdd 20170309 TSTAMP 设置为当前时间,默认格式:hhmm 2007 TODAY 设置为当前日期,带完整的月份 Ma ...
- 【java】控制台实现贪吃蛇小游戏-LinkedList、Scanner
package com.myproj.snake; public class Node { private int i,j; public Node(){} public Node(int i, in ...
- http中的get和post(二)
博客园精华区有篇文章< GET 和 POST 有什么区别?及为什么网上的多数答案都是错的 >,文中和回复多是对以下两个问题进行了深究: 长度限制 Url 是否隐藏数据 在我看来这两者都不是 ...