question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

electron-forge does not work with npm workspaces (npm v7)

See original GitHub issue

Preflight Checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version: 6.0.0-beta.57
  • Electron Version: 13.1.0
  • Operating System: macOS 11.4
  • Last Known Working Electron Forge version:: N/A

Expected Behavior

Running electron-forge start from project root (npm run start --workspace="packages/electron-app") or from electron workspace root (cd packages/electron-app && npm run start) should be able to locate the electron executable in the project root node_modules.

Actual Behavior

Running electron-forge start throws a PackageNotFoundError:

An unhandled rejection has occurred inside Forge:
PackageNotFoundError: Cannot find the package "electron". Perhaps you need to run "yarn install" in "<path-to-project-root>/packages/electron-app"?

To Reproduce

Minimal repro example: https://github.com/brightbrained/electron-forge-workspaces

Make sure to have npm v7 or above for workspaces support (npm install --global npm@latest)

git clone https://github.com/brightbrained/electron-forge-workspaces.git
cd electron-forge-workspaces
npm install
npm run start --workspace="packages/electron"

Additional Information

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

4reactions
robin-hartmanncommented, Mar 21, 2022

Here’s a working app using NPM workspaces: https://github.com/jeanbmar/black-moon-rewind/tree/r0.1-beta/packages/launcher In order to get Forge working til the end, I had to write my own dependency resolver (np-bundle) and call it in Forge hooks because electron-packager won’t resolve monorepo deps.

I also had to set packagerConfig: { prune: false } in my forge config file, but then your bundler worked.

Thank you very much!

2reactions
jeanbmarcommented, Feb 10, 2022

Here’s a working app using NPM workspaces: https://github.com/jeanbmar/black-moon-rewind/tree/r0.1-beta/packages/launcher In order to get Forge working til the end, I had to write my own dependency resolver (np-bundle) and call it in Forge hooks because electron-packager won’t resolve monorepo deps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron-forge does not work with npm workspaces (npm v7)
Running electron-forge start from project root ( npm run start --workspace="packages/electron-app" ) or from electron workspace root ( cd ...
Read more >
NPM 7 workspaces - how to install new package in workspace?
So far, the only workaround I can find is to edit the submodule0 package.json and add the somepackage manually. Then run npm i...
Read more >
@electron-forge/cli - npm
A complete tool for building modern Electron applications. Latest version: 6.0.4, last published: 8 days ago.
Read more >
Npm-check-updates NPM - npm.io
Run npm install to update your installed packages and package-lock.json. clean output; sensible defaults; lots of options for custom behavior ...
Read more >
could not determine executable to run npm err! a complete log ...
I ended up just installing electron-forge and then running import without npx . npm i -g @electron-forge/cli electron ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found