美文网首页
Mac环境安装Electron

Mac环境安装Electron

作者: dpkBat | 来源:发表于2018-01-07 15:14 被阅读0次
Electron

Electron简介

使用 JavaScript, HTML 和 CSS 构建跨平台的桌面应用。

Electron安装

1. 官网安装指南

2. 使用cnpm安装

国内使用npm安装Electron会报错,所以使用cnmp安装Electron

  • 安装npm:brew install node
  • 安装cnpm:npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 安装Electron:npm install electron -g

Electron快速入门

示例1:使用官网的electron-quick-start作为例子

# 克隆这仓库
$ git clone https://github.com/electron/electron-quick-start
# 进入仓库
$ cd electron-quick-start
# 安装依赖库
$ npm install
# 运行应用
$ npm start

示例2:使用全局依赖库

# 克隆这仓库
$ git clone https://github.com/electron/electron-quick-start
# 进入仓库
$ cd electron-quick-start
# 运行应用
$ npm start

使用Visual Studio Code开发

配置VS Code

配置一:针对示例1中,每个项目都有自己单独的依赖库,而不是使用全局依赖库的情况

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Electron Main",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
            "program": "${workspaceFolder}/main.js",
            "protocol": "legacy"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/main.js"
        }
    ]
}

配置二:针对示例2,使用全局依赖库的情况

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Electron Main",
        "runtimeExecutable": "/usr/local/bin/electron",
        "program": "${workspaceFolder}/main.js",
        "protocol": "legacy"
    },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}/main.js"
        }
    ]
}

相关文章

网友评论

      本文标题:Mac环境安装Electron

      本文链接:https://www.haomeiwen.com/subject/qnppnxtx.html