Electron + node.jsの開発環境構築と新規プロジェクト作成(Windows)

Electron + node.jsの開発環境構築と新規プロジェクト作成(Windows)

前提

npm,nodeはインストールされているものとします。

新規プロジェクト作成

nodeのプロジェクト作成します。

npm init -y
npm i --save-dev electron

electronはグローバルインストールでなくて大丈夫です。

Quick Start | Electron
This guide will step you through the process of creating a barebones Hello World app in Electron, similar to electron/electron-quick-start.

クイックスタートにある通り、メインプロセスをmain.jsとし、index.htmlをロードします。

package.json

npm scriptsに"start": "electron ."と記述します。

{
  "name": "create-app",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
    "start": "electron ."
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "electron": "^11.1.0"
  }
}

これで、npm startとタイプすればアプリが起動します。

次回はパッケージングしてEXEファイルを作成してみます。

コメント

タイトルとURLをコピーしました