Electron-Hello-World is a simple application built using Electron, an open-source framework developed by GitHub. This application serves as a basic template for starting Electron projects and demonstrates how to create a minimalistic "Hello World" desktop application.
- Displays a minimalist window with a "Hello, World!" message.
- Provides a foundation for building more complex Electron applications.
-
Clone the repository to your local machine:
git clone https://github.com/your-username/Electron-Hello-World.git
-
Navigate into the project directory:
cd Electron-Hello-World
-
Install dependencies using npm:
npm install
Once the installation is complete, you can run the Electron-Hello-World application by executing the following command in your terminal
npm start
This will launch the Electron application, displaying the "Hello, World!" message in a new window.
Contributions are welcome! If you have any ideas for improvements or new features, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
Node, NPM
mkdir my-electron-app && cd my-electron-app
npm init
npm install electron --save-dev
Should add Gitignore for
Node.js
Update "scripts"
on package,json
as following
"scripts": {
"start": "electron .", // Add this Line
"test": "echo \"Error: no test specified\" && exit 1"
},
Start App
npm run start
main.js
const { app, BrowserWindow } = require('electron');
function createWindow() {
const win = new BrowserWindow({
height: 600,
width: 800,
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true
},
icon: path.join(__dirname, 'assets', 'img', 'icon.png'),
title: 'My App',
});
win.setTitle('My App');
win.loadFile('views/index.html');
win.webContents.openDevTools();
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
npm install --save-dev @electron-forge/cli
npx electron-forge import
//...
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
//...
npm run make
More : Electron Tutorial