Repository navigation
Closed
Description
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
- Create a simple electron app using
electron-forge - yarn install
- 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.jsshows that the file exists. - With 18.1.2,
ls node_modules/\@electron/packager/shows that thesrc/directory no longer exists and was replaced bydist/.
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.
Reacted by alinmateutdev
Metadata
Metadata
Assignees
Labels
No labels
Activity
benbucksch commentedon Dec 19, 2023
Fixed by #3419. Thanks @erikian!
Leaving this open until this is released, given that everybody is broken right now.
FrostMiKu commentedon Dec 19, 2023
Sorry, how can I start a new project now?
erikian commentedon Dec 19, 2023
@FrostMiKu as a workaround, you can use Yarn's
resolutionsor npm'soverridesin 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" } }erikian commentedon Dec 19, 2023
Fixed by electron/packager#1641,
create-electron-appshould run as expected now. If it's still not working, you can uninstallcreate-electron-app(yarn global remove create-electron-app/npm uninstall -g create-electron-app) and then runyarn create electron-app/npx create-electron-appagain.JasonLeviGoodison commentedon Dec 19, 2023
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-appI still get the error:
Am I missing something?
benbucksch commentedon Dec 19, 2023
@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?
erikian commentedon Dec 19, 2023
@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-appwork again.Have you tried
npm uninstall -g create-electron-appbefore runningnpx create-electron-app new-app? Reinstallingcreate-electron-appshould force npm to use the latest Packager version.JasonLeviGoodison commentedon Dec 19, 2023
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-appworks vsnpm 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 packageserikian commentedon Dec 19, 2023
This might sound weird, but do you have Yarn installed on your machine? I think there's an open issue where
create-electron-appalways uses Yarn internally if it's available, even if you run it withnpx(#3164).If you do, try running
yarn global remove create-electron-app, thenyarn create electron-app new-appto see if it makes a difference.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.
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/35c48adf706267bcdirectory (or whatever path you're getting in your error message), this should force a clean install.JasonLeviGoodison commentedon Dec 19, 2023
Thank you so much for your help! The yarn commands change didn't work, but just manually deleting
/Users/jasongoodison/.npm/_npx/35c48adf706267bcseemed 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!