1.安装 node.js

链接:http://pan.baidu.com/s/1o7W7BIy 密码:y6od

一路next

我安装在F:\Program Files\node.js下

2.检查node.js和npm是否安装成功

  1. 命令行:node -v
  2. 命令行:npm -v

建议把npm的仓库切换到国内taobao仓库,

注册cnpm命令,如下

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

3. Electron的安装

cnpm install -g electron

electron是否安装成功可通过命令 electron -v 查看。

4. 打包输出工具

cnpm install -g electron-packager

5.electron 客户端工具

Electron.exe

链接:http://pan.baidu.com/s/1mieJnLI 密码:x2i8

安装完成双击electron.exe文件

 6.新建一个程序

新建一个文件夹,命名为electron,在文件夹目录下,创建三个文件,package.jsonmain.jsindex.html

文件夹目录的结构如下:

package.json

1 {
2 "name" : "your-app",
3 "version" : "0.1.0",
4 "main" : "main.js"
5 }
6
7

main.js

 1 const electron = require('electron');
2 // Module to control application life.
3 const {app} = electron;
4 // Module to create native browser window.
5 const {BrowserWindow} = electron;
6
7 // Keep a global reference of the window object, if you don't, the window will
8 // be closed automatically when the JavaScript object is garbage collected.
9 let win;
10
11 function createWindow() {
12 // Create the browser window.
13 win = new BrowserWindow({width: 800, height: 600});
14
15 // and load the index.html of the app.
16 win.loadURL(`file://${__dirname}/index.html`);
17
18 // Open the DevTools.
19 win.webContents.openDevTools();
20
21 // Emitted when the window is closed.
22 win.on('closed', () => {
23 // Dereference the window object, usually you would store windows
24 // in an array if your app supports multi windows, this is the time
25 // when you should delete the corresponding element.
26 win = null;
27 });
28 }
29
30 // This method will be called when Electron has finished
31 // initialization and is ready to create browser windows.
32 // Some APIs can only be used after this event occurs.
33 app.on('ready', createWindow);
34
35 // Quit when all windows are closed.
36 app.on('window-all-closed', () => {
37 // On OS X it is common for applications and their menu bar
38 // to stay active until the user quits explicitly with Cmd + Q
39 if (process.platform !== 'darwin') {
40 app.quit();
41 }
42 });
43
44 app.on('activate', () => {
45 // On OS X it's common to re-create a window in the app when the
46 // dock icon is clicked and there are no other windows open.
47 if (win === null) {
48 createWindow();
49 }
50 });
51
52 // In this file you can include the rest of your app's specific main process
53 // code. You can also put them in separate files and require them here.
 

index.html

 1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title>Hello World!</title>
6 </head>
7 <body>
8 <h1>Hello World!</h1>
9 We are using node <script>document.write(process.versions.node)</script>,
10 Chrome <script>document.write(process.versions.chrome)</script>,
11 and Electron <script>document.write(process.versions.electron)</script>.
12 </body>
13 </html>

7.运行程序

两种方法

1.命令行

在cmd里面写

Electron.exe安装路径

自己的文件夹的路径

2.拖

把你写的文件夹直接拖到electron.exe里面。

electron 安装使用的更多相关文章

  1. electron 安装

    1.从网上下载的是nodejs的v0.10.42版本的安装文件,安装node-v0.10.42-x86.msi都使用默认安装,安装完成后会安装在C:\Program Files\nodejs\目录下, ...

  2. Electron安装过程深入解析(读完此文解决Electron应用无法启动,无法打包的问题)

    1. 安装Electron依赖包 开发者往往通过npm install(或 yarn add)指令完成为Node.js工程安装依赖包的工作, 安装Electron也不例外,下面是npm和yarn的安装 ...

  3. Electron安装

    1.安装nodejs和npm 官网下载地址:https://nodejs.org/en/download/ 安装包:下载.msi 安装完成后: nodejs.npm都会安装好,path环境变量也自动设 ...

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

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

  5. electron安装到第一个实例

    1.node.js下载,然后安装.下载地址:链接:http://pan.baidu.com/s/1o7TONhS 密码:fosa 2.cmd下输入:npm install electron-prebu ...

  6. Electron 安装与使用

    Electron是使用 JavaScript, HTML 和 CSS 构建跨平台的桌面应用 本文基于Windows进行开发的过程,记录下来,以便日后使用,Electron官网:https://elec ...

  7. electron安装与使用

    系统 WIN10 X64 1. python-2.7.15.amd64.msi 2. node-v10.4.1-x64.msi 3. VS2015 community(社区版) 4. npm conf ...

  8. electron 安装失败解决办法

    1.安装node https://nodejs.org/en/download/2.安装镜像工具npm install -g cnpm --registry=https://registry.npm. ...

  9. 为Electron 安装 vue-devtool等扩展

    相关代码: https://github.com/WozHuang/Barrage-helper/blob/master/src/main/index.dev.js 在SPA逐渐成为构建优秀交互体验应 ...

随机推荐

  1. 动态调试smali代码

    Android Killer对应用进行反编译为smali代码,看看Manifest文件中application标签里面是否有android:debuggable="true",没有 ...

  2. Android开发——事件分发机制详解

    0. 前言   转载请注明出处:http://blog.csdn.net/seu_calvin/article/details/52566965 深入学习事件分发机制,是为了解决在Android开发中 ...

  3. P2183 巧克力(二分答案)

    P2183 巧克力 题目描述 佳佳邀请了M个同学到家里玩.为了招待客人,她需要将巧克力分给她的好朋友们.她有N(1<=N<=5000)块巧克力,但是大小各不一样,第i块巧克力大小为为1*X ...

  4. 《Cracking the Coding Interview》——第9章:递归和动态规划——题目1

    2014-03-20 02:55 题目:小朋友跳台阶,每次跳1层或2层,那么跳N层总共有多少种跳法. 解法:斐波那契数列. 代码: // 9.1 A child can run up the stai ...

  5. Python基础简介与简单使用

    Python介绍 Python发展史 1989年,为了打发圣诞节假期,Guido开始写Python语言的编译器.Python这个名字,来自Guido所挚爱的电视剧Monty Python’s Flyi ...

  6. 设计模式之模板方法模式 templateMethod

    代码实现 public abstract class BankTemplateMethod { //具体方法 public void takeNumber(){ System.out.println( ...

  7. diskimage-builder-command

    yum -y install python-virtualenv.noarch virtualenv ~/dib-virtualenv . ~/dib-virtualenv/bin/activate ...

  8. [转]LVS+Keepalived负载均衡配置

    简介 来源:https://www.cnblogs.com/MacoLee/p/5858995.html lvs一般是和keepalived一起组合使用的,虽然也可以单独使用lvs,但配置比较繁琐,且 ...

  9. ./configure, make, sudo make install 的含义

    一般编译安装会用到. 将压缩包example.tar.gz解压到onePackage下example, 在onePackage下新建install文件夹. 在终端中执行 1) 配置sudo ./con ...

  10. Python——开篇之词

    我也断断续续的用Python挺长时间了.但是一直都没有系统的学习过Python.很多东西都是现用现学.这样感觉对Python的理解太浅,完完全全就是搬砖的. 因此,我专门找了一个比较完整的老男孩的Py ...