1、安装node.js 例如:安装在 F://node 下;

2、cmd控制台:

F:

回车,进入F盘,

cd node

回车,进入node文件夹,

node -v

回车,查看node版本,

npm -v

回车,查看npm版本,若出现版本号,表示安装成功;

3、在cmd控制台,node文件夹下,把npm仓库切换到国内taobao仓库,速度会快很多,命令如下:

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

4、在node文件夹下,安装electron,命令如下:

  cnpm install -g electron

5、输入命令:

  electron -v

查看electron版本,若出现版本号,表示安装成功;

6、输入命令:

cnpm install -g electron-packager

打包输出工具;

7、下载并安装electron客户端;

8、新建一个项目文件夹,自命名,例如:test1;

9、在 test1 中创建:pakage.json、index.html、main.js 三个文件;

10、通过拖拽 test1 文件夹到 electron客户端,或者在cmd控制台中使用命令打开文件,

F:\electron1\electron.exe E:\electronCodes\test1

前段为客户端地址,后段为文件地址

附录:pakage.json、index.html、main.js

pakage.json:

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

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>

main.js:

const electron = require('electron');
// Module to control application life.
const {app} = electron;
// Module to create native browser window.
const {BrowserWindow} = electron;// 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(`file://${__dirname}/index.html`);// 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 OS X it is common for applications and their menu bar// to stay active until the user quits explicitly with Cmd + Qif (process.platform !== 'darwin') {app.quit();}
});app.on('activate', () => {// On OS X 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安装教程相关推荐

  1. electron 安装import_Electron: 从零开始写一个记事本app

    Electron介绍 简单来说,Electron就是可以让你用Javascript.HTML.CSS来编写运行于Windows.macOS.Linux系统之上的桌面应用的库.本文的目的是通过使用Ele ...

  2. Electron系列教程——第二篇:第一个示例

    Electron系列教程--第二篇:第一个示例 一.楔子 在正式开始音乐播放器项目之前,还需要来个简单的案例,以便更好的理解Electron.如果你已经使用过Electron,可以跳过这篇. 本篇将实 ...

  3. electron学习教程 基本教程已测试完成

    electron学习教程 1.介绍 2.五分钟快速上手 2.1 先创建index.html文件 2.2 再创建main.js文件 2.3 再安装electron 2.2 配置为入口文件 2.5 运行 ...

  4. 【网站汇总】安装教程系列

    目录 1.Anaconda 2.Pytorch 3.Tensorflow 4.LaTeX 5.博客搭建 1.Anaconda [CV]Anaconda 安装教程_Fannnnf的博客-CSDN博客 2 ...

  5. oracle 11g完全安装教程(CentOS)

    oracle下载链接:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html oracle ...

  6. vs安装一直在提取文件_Visual Studio 2019下载及安装教程

    宸1分钟前 这可是我珍藏多年的资源啊. Visual Studio 2019 Microsoft Visual Studio(简称VS)是美国微软公司的开发工具包系列产品.是目前最流行的Windows ...

  7. 这套完美的Java环境安装教程,完整,详细,清晰可观,让你一目了然,简单易懂。⊙﹏⊙...

    JDK下载与安装教程 2017年06月18日 22:53:16 Danishlyy1995 阅读数:349980 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csd ...

  8. iOS7系统iLEX RAT冬青鼠安装教程:无需刷机还原纯净越狱系统

    全网科技 温馨提醒:iLEX RAT和Semi-Restore的作用都是让你的已越狱的设备恢复至越狱的初始状态. 可是要注意无论你是用iLexRAT冬青鼠还是Semi-restore.对于还原来说都存 ...

  9. TensorFlow2.0 系列开篇: Windows下GPU版本详细安装教程

    点击上方"Datawhale",选择"星标"公众号 第一时间获取价值内容 [导读]今年三月谷歌在TensorFlow开发者峰会上宣布TensorFlow 2.0 ...

最新文章

  1. python操作mysql(二)
  2. 刚进美团,就被各种Code Review,真的有必要吗?
  3. python读取文件夹图片_读取文件夹里的图片,并且与标签对应
  4. python怎么安装requests库-Python3.6安装及引入Requests库
  5. PCB学习第一节内容整理
  6. C#中的平台调用(P/Invoke)
  7. java分数怎么保存到文件_Java如何将控制台上的结果保存到文件
  8. 从零开始学习docker(零)简单介绍Dockerfile
  9. IOS之导航控制器与表视图
  10. ng-bootstrap 组件集中 tabset 组件的实现分析
  11. 第3课 天安门广场 《小学生C++趣味编程》--C++、Scratch
  12. DVR服务器如何装系统,车载监控dvr如何配置服务器
  13. OSChina 周三乱弹 —— 程序员,老了会是怎么样?
  14. bilstmcrf词性标注_BiLSTM+CRF 的实现详解
  15. 【路径规划】基于matlab改进的粒子群算法路径规划【含Matlab源码 491期】
  16. treetable怎么带参数_jQuery.treetable使用及异步加载
  17. 海外邮件收发阻碍多?网易企业邮箱为您保驾护航【网易企业邮箱怎么申请】
  18. 11 种主要神经网络结构图解
  19. java笔记——(集合)
  20. 周报,当前是第几周 ?

热门文章

  1. C++数据共享与保护static活期存款篇
  2. Jquery 中 ajaxSubmit 、ajaxForm使用讲解
  3. ORACLE学习记录
  4. 高校学生成绩管理教务系统完整项目
  5. abex' creak me#1
  6. Chatbot-检索式模型介绍(一)
  7. ARouter 源码解析(1.5.2 版本)
  8. 每个程序员都应该了解:KISS:60年前美国军方的编程原则。
  9. flask html下拉列表,如何使用Flask和HTML從python列表創建下拉菜單
  10. C/C++ 扫雷游戏制作