forge icon indicating copy to clipboard operation
forge copied to clipboard

Error: Cannot find module '@electron-forge/plugin-fuses' when `npm run make` after importing manually created project

Open Lsnsh opened this issue 2 years ago • 8 comments

Pre-flight checklist

  • [x] I have read the contribution documentation for this project.
  • [X] I agree to follow the code of conduct that this project uses.
  • [X] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.3.0

Electron version

v29.0.1

Operating system

macOS 13.6.1

Last known working Electron Forge version

No response

Expected behavior

No missing required modules after import, and work normally

Actual behavior

Error: Cannot find module '@electron-forge/plugin-fuses', make failed

Steps to reproduce

  1. manually create project(https://www.electronjs.org/docs/latest/tutorial/tutorial-first-app)
  2. ...
  3. check devDependencies only have electron in package.json
  4. import project(https://www.electronjs.org/docs/latest/tutorial/tutorial-packaging)
    1. npm install --save-dev @electron-forge/cli
    2. npx electron-forge import
  5. npm run make

Additional information

package.json:
{
  "name": "first-electron-app",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "scripts": {
-   "start": "electron .",
+   "start": "electron-forge start",
-   "test": "echo \"Error: no test specified\" && exit 1"
+   "test": "echo \"Error: no test specified\" && exit 1",
+   "package": "electron-forge package",
+   "make": "electron-forge make"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
+   "@electron-forge/cli": "^7.3.0",
+   "@electron-forge/maker-deb": "^7.3.0",
+   "@electron-forge/maker-rpm": "^7.3.0",
+   "@electron-forge/maker-squirrel": "^7.3.0",
+   "@electron-forge/maker-zip": "^7.3.0",
+   "@electron-forge/plugin-auto-unpack-natives": "^7.3.0",
    "electron": "^29.0.1"
+ },
+ "dependencies": {
+   "electron-squirrel-startup": "^1.0.0"
 }
}
forge.config.js:
const { FusesPlugin } = require('@electron-forge/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
  packagerConfig: {
    asar: true,
  },
  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: {},
    },
  ],
  plugins: [
    {
      name: '@electron-forge/plugin-auto-unpack-natives',
      config: {},
    },
    // Fuses are used to enable/disable various Electron functionality
    // at package time, before code signing the application
    new FusesPlugin({
      version: FuseVersion.V1,
      [FuseV1Options.RunAsNode]: false,
      [FuseV1Options.EnableCookieEncryption]: true,
      [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
      [FuseV1Options.EnableNodeCliInspectArguments]: false,
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
      [FuseV1Options.OnlyLoadAppFromAsar]: true,
    }),
  ],
};

Lsnsh avatar Feb 25 '24 16:02 Lsnsh

I also encountered the same error.

I solved mine by additionally running the following command: devDependency seems to be missing at npx electron-forge import .

$ npm install --save-dev @electron-forge/plugin-fuses

The devDependency list is implemented in the following code, which could be added here.

https://github.com/electron/forge/blob/1aa94fc32754ffd07a3652db42952f1f22ddbd6c/packages/api/core/src/api/init-scripts/init-npm.ts#L18-L25

rabitarochan avatar Feb 28 '24 08:02 rabitarochan

npm install --save-dev @electron-forge/plugin-fuses then npm run make again worked for me~

lingchuL avatar Feb 28 '24 08:02 lingchuL

+1 on this. Came here to report this issue

tsekiguchi avatar Feb 29 '24 02:02 tsekiguchi

+1. Faced the same problem.

After installing @electron-forge/plugin-fuses in devDependencies "npm run make" works without errors:

npm install @electron-forge/plugin-fuses --save-dev

timofey-ivashchenko avatar Feb 29 '24 16:02 timofey-ivashchenko

+1 same problem, same solution

AuWiMo avatar Mar 03 '24 20:03 AuWiMo

Yes, baby !

Crownico avatar Mar 04 '24 18:03 Crownico

I also encountered the same error.

I solved mine by additionally running the following command: devDependency seems to be missing at npx electron-forge import .

$ npm install --save-dev @electron-forge/plugin-fuses

The devDependency list is implemented in the following code, which could be added here.

https://github.com/electron/forge/blob/1aa94fc32754ffd07a3652db42952f1f22ddbd6c/packages/api/core/src/api/init-scripts/init-npm.ts#L18-L25

This worked out for me! Thx

Luktaros avatar Mar 05 '24 03:03 Luktaros

Thanks for this solution

mbelasergesedi avatar Mar 11 '24 23:03 mbelasergesedi

Thanks for the solution. Worked for me.

shivkumarojha avatar Mar 23 '24 15:03 shivkumarojha

+1, used solutions available and it worked for me.

JustAnEric avatar Mar 24 '24 14:03 JustAnEric