Setup and Installation
Prerequisites
Before you start developing with Electron, you need to have Node.js installed on your system. Node.js includes npm (Node Package Manager), which you'll use to install Electron and other dependencies.
Make sure you have Node.js installed first. You can download it from nodejs.org.
Installing Electron
To get started, install Electron via npm. It's recommended to install Electron as a development dependency in your project:
npm install electron --save-dev
This command will download Electron and add it to your project's devDependencies in the package.json file.
Installation Steps
- Install Node.js - Download and install Node.js from the official website
- Create a project directory - Set up a new folder for your Electron application
- Initialize npm - Run
npm initto create apackage.jsonfile - Install Electron - Run
npm install electron --save-devto add Electron to your project
Project Setup
After installing Electron, your project structure should look like this:
my-electron-app/
├── node_modules/
├── package.json
├── package-lock.json
└── main.js (to be created)
Verifying Installation
You can verify that Electron is installed correctly by checking its version:
npx electron --version
This should display the installed Electron version number.