Skip to content

Package causing error on app openΒ #162

@luuukee

Description

@luuukee

Hi, I'm having an issue where whenever I build my application into a ZIP or a DMG for macOS/darwin and I open the application, it returns the error:

Error: Cannot find module 'update-electron-app'
Require stack:
- /Users/user/Documents/Appname/electron/out/Appname-darwin-arm64/Appname.app/Contents/Resources/app.asar/.vite/build/main.js
- 
at Module._resolveFilename (node:internal/modules/cjs/loader:1232:15)
at s._resolveFilename (node:electron/js2c/browser_init:2:123740)
at Module._load (node:internal/modules/cjs/loader:1058:27)
at c._load (node:electron/js2c/node_init:2:16955)
at Module.require (node:internal/modules/cjs/loader:1318:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/Users/user/Documents/Appname/electron/out/Appname-darwin-arm64/Appname.app/Contents/Resources/app.asar/.vite/build/main.js:1:208)
at Module._compile (node:internal/modules/cjs/loader:1484:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1564:10)
at Module.load (node:internal/modules/cjs/loader:1295:32)

My forge config:

const config: ForgeConfig = {
  packagerConfig: {
    asar: true,
    icon: "./src/assets/logo.ico",
    protocols: [
      {
        name: "Appname",
        schemes: ["appname"]
      }
    ]
  },
  rebuildConfig: {},
  makers: [
    {
      name: "@electron-forge/maker-squirrel",
      config: (arch: any) => ({
        loadingGif: "./src/assets/loading.gif",
        iconUrl: "https://s3.appname.com/static/appname-logo.svg",
        setupIcon: `./src/assets/logo.ico`,
        remoteReleases: `https://s3.appname.com/appname/releases/win32/${arch}`,
      }),
    },
    {
      name: "@electron-forge/maker-zip",
      config: {
        platform: "darwin",
      }
    }
  ],
  publishers: [
    {
      name: '@electron-forge/publisher-s3',
      config: {
        bucket: 'Appname',
        keyResolver: (fileName: any, platform: any, arch: any) => {
          return `Appname/releases/${platform}/${arch}/${fileName}`
        },
        public: true,
        region: 'auto',
        accessKeyId: process.env.AWS_ACCESS_KEY_ID,
        secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
        endpoint: process.env.AWS_ENDPOINT_URL,
        folder: 'Appname'
      }
    }
  ],
  plugins: [
    new VitePlugin({
      // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
      // If you are familiar with Vite configuration, it will look really familiar.
      build: [
        {
          // `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
          entry: "src/main.ts",
          config: "vite.main.config.ts",
        },
        {
          entry: "src/preload.ts",
          config: "vite.preload.config.ts",
        },
        {
          entry: "src/webviewpreload.ts",
          config: "vite.preload.config.ts",
        }
      ],
      renderer: [
        {
          name: "main_window",
          config: "vite.renderer.config.ts",
        },
      ],
    }),
    // 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,
    }),
  ],
};

export default config;

I'm running on macOS Monterey 12.5 and Bun 1.1.33.
I've tried multiple times to remove all node_modules, reinstall them, update them, etc, but nothing seems to fix my problem.
Any help would be greatly appreciated, thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions