Skip to content

Electron Packager 18.1.2 breaks electron-forge #3443

Closed

Description

@benbucksch

Pre-flight checklist

  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Electron Forge version

7.2.0

Electron version

28.0.0

Operating system

Ubuntu 20.04 x64

Last known working Electron Forge version

7.2.0 (Same)

Expected behavior

  • Electron starts

Actual behavior

$ electron-forge start

An unhandled exception has occurred inside Forge:
Cannot find module '@electron/packager/src/targets'
Require stack:
- .../node_modules/@electron-forge/core/dist/util/parse-archs.js
- .../node_modules/@electron-forge/core/dist/api/make.js
- .../node_modules/@electron-forge/core/dist/api/index.js
- .../node_modules/@electron-forge/cli/dist/util/check-system.js
- .../node_modules/@electron-forge/cli/dist/electron-forge.js
Error: Cannot find module '@electron/packager/src/targets'
Require stack:
- .../node_modules/@electron-forge/core/dist/util/parse-archs.js
- .../node_modules/@electron-forge/core/dist/api/make.js
- .../node_modules/@electron-forge/core/dist/api/index.js
- .../node_modules/@electron-forge/cli/dist/util/check-system.js
- .../node_modules/@electron-forge/cli/dist/electron-forge.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (.../node_modules/@electron-forge/core/dist/util/parse-archs.js:5:51)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
error Command failed with exit code 1.

Steps to reproduce

  1. Create a simple electron app using electron-forge
  2. yarn install
  3. yarn start

Additional information

When I downgrade using yarn add @electron/[email protected] and do yarn start, Electron starts. When I upgrade again using yarn add @electron/[email protected] and do yarn start, the above problem appears.

  • With 18.1.1, ls node_modules/\@electron/packager/src/targers.js shows that the file exists.
  • With 18.1.2, ls node_modules/\@electron/packager/ shows that the src/ directory no longer exists and was replaced by dist/.

The release notes of Electron Packager only mention documentation changes. But it appears the entire TypeScript rewrite #1593 was shipped crediting as "update broken doc link".

Fixes

Work with Electron Packager (issue #1673) to create a stable export in electron/packager for Electron Forge to use.

Activity

  1. benbucksch commented on Dec 19, 2023

    @benbucksch
    Author

    Fixed by #3419. Thanks @erikian!

    Leaving this open until this is released, given that everybody is broken right now.

  2. FrostMiKu commented on Dec 19, 2023

    @FrostMiKu

    Sorry, how can I start a new project now?

  3. erikian commented on Dec 19, 2023

    @erikian
    Member

    @FrostMiKu as a workaround, you can use Yarn's resolutions or npm's overrides in your package.json to use a previous Packager version until a new Forge version is released:

    Yarn:

    {
      "resolutions": {
        "@electron/packager": "18.1.1"
      }
    }

    npm:

    {
      "overrides": {
        "@electron/packager": "18.1.1"
      }
    }
  4. pinned this issue on Dec 19, 2023
  5. erikian commented on Dec 19, 2023

    @erikian
    Member

    Fixed by electron/packager#1641, create-electron-app should run as expected now. If it's still not working, you can uninstall create-electron-app (yarn global remove create-electron-app / npm uninstall -g create-electron-app) and then run yarn create electron-app / npx create-electron-app again.

  6. unpinned this issue on Dec 19, 2023
  7. JasonLeviGoodison commented on Dec 19, 2023

    @JasonLeviGoodison

    Are you sure the new version of electron-forge is published? I could be mistaken, but I still see 18.1.2 in package.json and when I run:
    npx create-electron-app new-app

    I still get the error:

    node:internal/modules/cjs/loader:1051
      throw err;
      ^
    
    Error: Cannot find module '@electron/packager/src/targets'
    Require stack:
    - /Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/util/parse-archs.js
    - /Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/api/make.js
    - /Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/api/index.js
    - /Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/cli/dist/electron-forge-init.js
    - /Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/create-electron-app/dist/index.js
        at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
        at Module._load (node:internal/modules/cjs/loader:901:27)
        at Module.require (node:internal/modules/cjs/loader:1115:19)
        at require (node:internal/modules/helpers:119:18)
        at Object.<anonymous> (/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/util/parse-archs.js:5:51)
        at Module._compile (node:internal/modules/cjs/loader:1233:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
        at Module.load (node:internal/modules/cjs/loader:1091:32)
        at Module._load (node:internal/modules/cjs/loader:938:12)
        at Module.require (node:internal/modules/cjs/loader:1115:19) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/util/parse-archs.js',
        '/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/api/make.js',
        '/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/core/dist/api/index.js',
        '/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/@electron-forge/cli/dist/electron-forge-init.js',
        '/Users/jasongoodison/.npm/_npx/35c48adf706267bc/node_modules/create-electron-app/dist/index.js'
      ]
    }
    
    Node.js v20.4.0
    npm ERR! code 1
    npm ERR! path /Users/jasongoodison/Documents/dev
    npm ERR! command failed
    npm ERR! command sh -c create-electron-app lawyer-screencap --template=webpack
    
    npm ERR! A complete log of this run can be found in: /Users/jasongoodison/.npm/_logs/2023-12-19T19_07_21_001Z-debug-0.log
    

    Am I missing something?

  8. benbucksch commented on Dec 19, 2023

    @benbucksch
    Author

    @JasonLeviGoodison There was no release yet. Last release of electron-forge was 7.2.0, released 3 weeks ago.
    @erikian Could you please make an emergency release?

  9. erikian commented on Dec 19, 2023

    @erikian
    Member

    Are you sure the new version of electron-forge is published

    @JasonLeviGoodison we released a new version of Packager containing the missing file that Forge needs, so there's no new Forge version right now since Packager v18.1.3 should be enough to make create-electron-app work again.

    Have you tried npm uninstall -g create-electron-app before running npx create-electron-app new-app? Reinstalling create-electron-app should force npm to use the latest Packager version.

  10. JasonLeviGoodison commented on Dec 19, 2023

    @JasonLeviGoodison

    No, even after global uninstall it doesn't work. This isn't exactly my wheelhouse, but isnt that expected?
    npx should be using the latest in npm registry if I'm understanding its use correctly.

    My understanding is that this repo needs to update its version of packager, which is currently 18.1.2, but should be 18.1.3 (unless you also released a hotfix on 18.1.2).

    Im not 100% sure how create-electron-app works vs npm init electron-app@latest, but it feels like they should both work out of box to me. I've uninstalled all global versions of electron and electron forge, and also am using npx to make sure im using up-to-date packages

  11. erikian commented on Dec 19, 2023

    @erikian
    Member

    This might sound weird, but do you have Yarn installed on your machine? I think there's an open issue where create-electron-app always uses Yarn internally if it's available, even if you run it with npx (#3164).

    If you do, try running yarn global remove create-electron-app, then yarn create electron-app new-app to see if it makes a difference.

    I've uninstalled all global versions of electron and electron forge

    Just in case you've reinstalled them, it's a good idea to uninstall any global versions of both Electron and Forge (and pretty much anything else from the Electron org 😄), as they can cause some weird conflicts. They are meant to be installed at the project-level, not globally.

    npx should be using the latest in npm registry if I'm understanding its use correctly

    That's correct. Forge specifies "@electron/packager": "^18.1.2" in its package.json, which means that any clean installs will use the most recent version in the 18.x.y series (18.1.3). If all else fails, you can manually delete the /Users/jasongoodison/.npm/_npx/35c48adf706267bc directory (or whatever path you're getting in your error message), this should force a clean install.

  12. JasonLeviGoodison commented on Dec 19, 2023

    @JasonLeviGoodison

    Thank you so much for your help! The yarn commands change didn't work, but just manually deleting /Users/jasongoodison/.npm/_npx/35c48adf706267bc seemed to do the trick.

    Just for the record, I definitely wasn't going to keep a global install around ahah 😅 I just tried a lot of random stuff last night when having this problem in hope that something would fix it.

    Good to go now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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