npm run make is not working in electron-forge

Viewed 5342

I have created and electron application and trying to use electron forge for building purpose. Please find below command which i have run it for creating the electron application:

   #npm i -g create-react-app
   #npm i -g @electron-forge/cli
   #npx create-electron-app my-ele-app

The above last command created a project my-ele-app. and now i am able to start the application as well. #npm start.

content of package.json file is:

{
  "name": "my-ele-app",
  "productName": "my-ele-app",
  "version": "1.0.0",
  "description": "My Electron application description",
  "main": "src/index.js",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make",
    "publish": "electron-forge publish",
    "lint": "echo \"No linting configured\""
  },
  "keywords": [],
  "author": {
    "name": "rohit",
    "email": "rohit@xyz.com"
  },
  "license": "MIT",
  "config": {
    "forge": {
      "packagerConfig": {},
      "makers": [
        {
          "name": "@electron-forge/maker-squirrel",
          "config": {
            "name": "my_ele_app"
          }
        },
        {
          "name": "@electron-forge/maker-zip",
          "platforms": [
            "darwin"
          ]
        },
        {
          "name": "@electron-forge/maker-deb",
          "config": {}
        },
        {
          "name": "@electron-forge/maker-rpm",
          "config": {}
        }
      ]
    }
  },
  "dependencies": {
    "electron-squirrel-startup": "^1.0.0"
  },
  "devDependencies": {
    "@electron-forge/cli": "^6.0.0-beta.55",
    "@electron-forge/maker-deb": "^6.0.0-beta.55",
    "@electron-forge/maker-rpm": "^6.0.0-beta.55",
    "@electron-forge/maker-squirrel": "^6.0.0-beta.55",
    "@electron-forge/maker-zip": "^6.0.0-beta.55",
    "electron": "12.0.9"
  }
}

Now when i am running below command, it is throwing error:

#npm run make

Error is:

> my-ele-app@1.0.0 make
> electron-forge make

√ Checking your system
√ Resolving Forge Config

An unhandled rejection has occurred inside Forge:
Error: Could not find module with name: @electron-forge/maker-squirrel. Make sure it's listed in the devDependencies of your package.json
    at _default (C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\@electron-forge\core\src\api\make.ts:125:15)
    at C:\Users\212807091\Desktop\Rohit\Office Note\RBAC\Electron_project\npx_electrong\my-ele-app\node_modules\@electron-forge\cli\src\electron-forge-make.ts:44:5

Electron Forge was terminated. Location:
{}

NOTE: i can see there is module available in node_modules folder: my-ele-app\node_modules@electron-forge\maker-squirrel

If anyone here has any idea how to fix this issue. please provide the answer. Thanks!

5 Answers

I got the same error after following the "Getting Started" instructions. Nothing resolved it until I ran npm install -g @electron-forge/cli@beta -- after that finished I was able to successfully run electron-forge make. Also running npm run make did the same as electron-forge make as I didn't appear to have it installed. Another thing I noticed is that if I run npm run make with maker-squirrel at version 6.0.0-beta.55 then I get this error: Could not find module with name: @electron-forge/maker-squirrel. However, if I re-install maker-squirrel as npm install --save-dev @electron-forge/maker-squirrel@6.0.0-beta.33 and re-run npm run make then I get an out folder with an exe.

you have installed all the required dependencies so just run this command

npm run package

And after this a folder with name out is generated and inside that your .exe file will be present

In my cases, it makes error when the description or author is empty in package.json file.

If you are using Windows, this works for me:

Run npm i electron-winstaller --save-dev --ignore-scripts

Install 7zip x86 in your computer. After installed, go to C:\Program Files (x86)\7-Zip and copy both 7z.dll and 7z.exe files to /path/to/your_project/node_modules/electron-winstaller/vendor if they are not still there.

Run npx electron-forge import again

Then try run npm run make again. I hope it works.

Related