Configuring the 'electron .' Command in package.json: A Proper Way to Start Your Electron Project

  • To configure the `electron .` command in the `package.json` file and start your Electron project easily, follow these steps:
  • Step 1: Open your project's `package.json` file.
  • Step 2: Locate the `"scripts"` section in the `package.json` file. If it doesn't exist, add it as follows:


  "scripts": {
    "start": "electron ."
  }

  • Step 3: Save the changes to `package.json`.
  • Now, you can start your Electron project by running a simple command.
  • Step 4: Open a terminal or command prompt in the root directory of your project.
  • Step 5: Run the following command:


    npm start

  • This command executes the script specified under the `"start"` key in the `"scripts"` section of `package.json`, which is now set to `electron .`. It launches your Electron application with the current directory as the project root.
  • With this configuration, you can easily start your Electron project by running the `npm start` command, saving you the hassle of typing `electron .` every time.

No comments:

Post a Comment