Electron-forge - An unhandled rejection has occurred inside Forge: [object Object]
Asked Answered
C

5

5

Tried to build an electron based app by running npm run make in terminal, everything went fine except when it had to go thru Making distributables. Out folder has been created but app is not bundled in one exe.

dependencies in Package.json

  "devDependencies": {
    "@electron-forge/cli": "^6.0.3",
    "@electron-forge/maker-deb": "^6.0.3",
    "@electron-forge/maker-rpm": "^6.0.3",
    "@electron-forge/maker-squirrel": "^6.0.3",
    "@electron-forge/maker-zip": "^6.0.3",
    "electron": "^6.1.12"
  },

config in forge.config.js:
module.exports = {
  packagerConfig: {},
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-forge/maker-squirrel',
      config: {},
    },
    {
      name: '@electron-forge/maker-zip',
      platforms: ['darwin'],
    },
    {
      name: '@electron-forge/maker-deb',
      config: {},
    },
    {
      name: '@electron-forge/maker-rpm',
      config: {},
    },
  ],
};

Full error I'm getting
any solutions?

Canaday answered 16/11, 2022 at 7:35 Comment(1)
Hey there, we're working on fixing the [object Object] bug in the error logging. Forge v6.0.4 should provide a more descriptive error message going forward. See github.com/electron/forge/pull/3086Vazquez
F
8

Make sure you have author and description properties not empty in package.json like so: "author": "John".

Here is a full example:

{
  "name": "test",
  "version": "1.0.0",
  "description": "test",
  "main": "index.js",
  "scripts": {
    "start": "electron-forge start",
    "package": "electron-forge package",
    "make": "electron-forge make"
  },
  "author": "John",
  "license": "ISC",
  "devDependencies": {
    "@electron-forge/cli": "^6.0.3",
    "@electron-forge/maker-deb": "^6.0.3",
    "@electron-forge/maker-rpm": "^6.0.3",
    "@electron-forge/maker-squirrel": "^6.0.3",
    "@electron-forge/maker-zip": "^6.0.3",
    "electron": "^21.2.3"
  },
  "dependencies": {
    "electron-squirrel-startup": "^1.0.0"
  }
}

It seems like a weird bug, but this fix worked for me.

Faggoting answered 17/11, 2022 at 0:4 Comment(0)
C
1

I ran into the exact same issue and I fixed it by writing something in the description in the package.json file.

{
  ...
  description: "an electron test app",
  ...
}

https://www.electronforge.io/config/makers/squirrel.windows#in-package.json

Caldeira answered 18/11, 2022 at 20:23 Comment(0)
M
1

I was getting the same error:

An unhandled rejection has occurred inside Forge:
[object Object]

Here [object object] indicates that some values are empty in the package.json file.

e.g. in my case it was author and description.

Solution : Just provide some values other than empty, and npm run make should work as expected.

Magel answered 19/11, 2022 at 14:27 Comment(0)
A
1

try this config in forge.config.js and add author and description in your package.json

    {
      name: '@electron-forge/maker-squirrel',
      config: {
        authors: 'My Name',
        description: 'My Description',
      },
    },
April answered 29/11, 2022 at 14:19 Comment(1)
I had to add authors and description here as well. Already had it in my package.json though. Kinda ridiculous if you ask me.Contrary
C
0

As the selected answer mentions, this is due to a potential conflict in ES Modules and Common JS.

In my case, I had scaffolded with Vite and then ran npx electron-forge import and got this error.

A simple fix was to remove "type":module from package.json

Cordes answered 29/1 at 14:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.