package.json
{
"name": "my-electron-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "electron index.js"
},
"author": "",
"license": "ISC",
"devDependencies": {
"electron-packager": "^7.3.0",
"electron-prebuilt": "^1.3.1"
}
}
index.js
const {app, BrowserWindow} = require('electron');
let win;
function createWindow() {
win = new BrowserWindow({width: 800, height: 600});
win.loadURL(`file://${__dirname}/index.html`);
win.on('closed', () => { win = null; });
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
index.html
<!doctype html>
<html>
<body>
<h1>my-electron-app</h1>
</body>
</html>
以上のファイルをプロジェクトのルートディレクトリに作成し、$ npm install
と$ npm run start
で起動します。お疲れ様でした。