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 yarn workspaces

See original GitHub issue
  • 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 an issue that matches the one I want to file, without success.

Since I use Yarn workspaces electron-forge complains about missing dependencies which are installed through yarn in parent folder. My directory structure is as following:

omnicrom/
├─ node_modules/
│   ├──.bin/
│   ├── electron-forge
│   ├── electron
│   └── ...
├─ .../
└─ packages/
   └─ app/
      ├── .../
      ├── node_modules/
      │  └──.bin/
      └── src/
Console Output (with stack)
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Checking your system +0ms
  electron-forge:lifecycle Process Succeeded: Checking your system +517ms
  electron-forge:runtime-config setting key: verbose to value: false +0ms
WARNING: DEBUG environment variable detected.  Progress indicators will be sent over electron-forge:lifecycle
  electron-forge:lifecycle Process Started: Locating Application +0ms
  electron-forge:project-resolver searching for project in: D:\projects\crm\omnicrom\packages\app +0ms
  electron-forge:project-resolver electron-forge compatible package.json found in D:\projects\crm\omnicrom\packages\app\package.json +7ms
  electron-forge:lifecycle Process Succeeded: Locating Application +10ms
  electron-forge:util Could not read package.json for moduleName=electron-prebuilt-compile [Error: ENOENT: no such file or directory, open 'D:\projects\crm\omnicrom\packages\app\node_modules\electron-prebuilt-compile\package.json'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\projects\\crm\\omnicrom\\packages\\app\\node_modules\\electron-prebuilt-compile\\package.json'
} +0ms
  electron-forge:util Could not read package.json for moduleName=electron [Error: ENOENT: no such file or directory, open 'D:\projects\crm\omnicrom\packages\app\node_modules\electron\package.json']
{
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\projects\\crm\\omnicrom\\packages\\app\\node_modules\\electron\\package.json'
} +4ms
  electron-forge:util Could not read package.json for moduleName=electron-prebuilt [Error: ENOENT: no such file or directory, open 'D:\projects\crm\omnicrom\packages\app\node_modules\electron-prebuilt\package.json'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\projects\\crm\\omnicrom\\packages\\app\\node_modules\\electron-prebuilt\\package.json'
} +2ms
  electron-forge:util getElectronVersion failed to determine Electron version: projectDir=D:\projects\crm\omnicrom\packages\app, result=null +1ms

An unhandled rejection has occurred inside Forge: Could not determine Electron version. Make sure that ‘npm install’ (or ‘yarn’) has been run before invoking electron-forge. Error: Could not determine Electron version. Make sure that ‘npm install’ (or ‘yarn’) has been run before invoking electron-forge. at D:\projects\crm\omnicrom\node_modules\electron-forge\dist\util\rebuild.js:26:13 at Generator.next (<anonymous>) at Generator.tryCatcher (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\util.js:16:23) at PromiseSpawn._promiseFulfilled (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\generators.js:97:49) at D:\projects\crm\omnicrom\node_modules\bluebird\js\release\generators.js:201:15 at D:\projects\crm\omnicrom\node_modules\electron-forge\dist\util\rebuild.js:63:17 at D:\projects\crm\omnicrom\node_modules\electron-forge\dist\api\start.js:105:33 at Generator.next (<anonymous>) at Generator.tryCatcher (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\util.js:16:23) at PromiseSpawn._promiseFulfilled (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\generators.js:97:49) at Promise._settlePromise (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\promise.js:574:26) at Promise._settlePromise0 (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\promise.js:614:10) at Promise._settlePromises (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\promise.js:694:18) at _drainQueueStep (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\async.js:138:12) at _drainQueue (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\async.js:131:9) at Async._drainQueues (D:\projects\crm\omnicrom\node_modules\bluebird\js\release\async.js:147:5)

What command line arguments are you passing?

none.

What does your config.forge data in package.json look like?

config.forge settings
"config": {
    "forge": {
      "make_targets": {
        "win32": [
          "squirrel"
        ],
        "darwin": [
          "zip"
        ],
        "linux": [
          "deb",
          "rpm"
        ]
      },
      "electronPackagerConfig": {
        "packageManager": "yarn"
      },
      "electronWinstallerConfig": {
        "name": "omnicrom"
      },
      "electronInstallerDebian": {},
      "electronInstallerRedhat": {},
      "github_repository": {
        "owner": "",
        "name": ""
      },
      "windowsStoreConfig": {
        "packageName": "",
        "name": "omnicrom"
      }
    }
  }

To recreate this issue simply create a new project with electron-forge and then wrap it into a yarn workspace. to do this you refer to this guide: https://yarnpkg.com/en/docs/workspaces You could also recreate my directory structure and use the following root package.json contents:

{
  "name": "myrootpackage",
  "version": "1.0.0",
  "private": true,
  "workspaces": [
    "packages/*"
  ]
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:23 (7 by maintainers)

github_iconTop GitHub Comments

8reactions
alxmironcommented, Mar 18, 2020

Had the same problem. Fixed this by moving electron package from ./node_modules to ./packages/app/node_modules using yarn workspaces.noihoist

7reactions
alxmironcommented, Mar 20, 2020

@abumalick has correct testcase - I also get an error "electron package not found" there, unless I add the following props to my-new-app/package.json:

"private": true,
"workspaces": {
  "nohoist": [
    "electron",
    "electron/**",
    "electron-squirrel-startup",
    "electron-squirrel-startup/**",
    "@electron-forge",
    "@electron-forge/**"
  ]
},

NOTE: "private": true is important

Read more comments on GitHub >

github_iconTop Results From Across the Web

electron-forge does not work with yarn workspaces · Issue #869
I have searched the issue tracker for an issue that matches the one I want to file, without success. Since I use Yarn...
Read more >
yarn workspace nohoist - Chris Biscardi
When working with electron-forge and yarn workspaces, I ran into an issue where forge was looking for an electron package in the package-local ......
Read more >
Monorepo with both Lerna/Yarn Workspaces and electron ...
Hi there, I'm working on an IDE that is trying to house both the Development and Production environments in one repository.
Read more >
How to specify custom dist folder in electron-forge
I'm using yarn workspaces and my electron ...
Read more >
Trezy on Twitter: "I was trying to set up an @ElectronJS app with ...
The issue is that, because of the way workspaces work in Yarn 1, I had to move my dev deps to the root...
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