-
-
Notifications
You must be signed in to change notification settings - Fork 516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
electron-forge does not work with npm workspaces (npm v7) #2306
Comments
This relates to an old issue: #869 But the fix only accounts for yarn workspaces... |
I am running into exactly the same issue. Surprisingly |
I was having this problem but fixed it by deleting a |
If you read this and use NPM workspaces, you probably wonder why this issue is closed since it still doesn't work at all. @malept This issue should be reopened. |
Here's a working app using NPM workspaces: https://github.com/jeanbmar/black-moon-rewind/tree/r0.1-beta/packages/launcher |
I also had to set Thank you very much! |
Thank you @robin-hartmann. To give full credit to its author, my package is a modified version of npm/cli#4082. Your code looks great, you might want to share some feedback in the npm PR :). |
Thank you for the link. |
Hi should we re-open this, or is there an issue on I've been on a rollercoaster trying to get electron forge and its dependencies working, moving away from pnpm + workspaces to npm + workspaces and then needing the above fix... really just wanted this all to work out of the box 🥲. Pnpm support basically needs the same treatment as there is getting the core CLI working with pnpm, and then there is getting |
Truth is neither NPM or Electron cares about packaging monorepo. This pull request has been open for 1.5 year at NPM, and everyone involved just "ghosted" it. Forge support for workspaces consists in letting NPM workspaces find Electron in the node_modules and completely ignores the fact that workspaces can't be packaged 🙃. PNPM is probably the safe bet here. |
For what it's worth, we've been using |
What do you do about electron packager and copying node modules over? Or you aren't using workspaces? |
Our app is a React app. Our repo is structured like this:
Our top-level {
"name": "example-root",
"version": "1.0.0",
"private": true,
"scripts": {
"web-run-dev": "yarn workspace example-web run run-dev",
"web-build-prod": "yarn workspace example-web run build-prod",
"app-run-dev": "yarn workspace example-app run run",
"app-build-prod": "yarn workspace example-app run package"
},
"workspaces": [
"app",
"web",
"src"
],
"devDependencies": {
"eslint": "8.29.0",
"eslint-plugin-react": "7.31.11",
"eslint-plugin-react-hooks": "4.6.0"
},
"packageManager": "yarn@3.3.0"
}
{
"name": "example-app",
"productName": "Example",
"version": "0.0.1",
"private": true,
"scripts": {
"run": "electron-forge start",
"package": "electron-forge package --platform win32 --arch ia32"
},
"main": ".webpack/main",
"config": {
"forge": {
"packagerConfig": {
"download": {
"cacheRoot": "local-electron-cache"
}
},
"makers": [],
"plugins": [
{
"name": "@electron-forge/plugin-webpack",
"config": {
"devContentSecurityPolicy": "default-src * self blob: data: gap:; style-src * self 'unsafe-inline' blob: data: gap:; script-src * 'self' 'unsafe-eval' 'unsafe-inline' blob: data: gap:; object-src * 'self' blob: data: gap:; img-src * self 'unsafe-inline' blob: data: gap:; connect-src self * 'unsafe-inline' blob: data: gap:; frame-src * self blob: data: gap:;",
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "../src/index.ejs",
"js": "./renderer.js",
"name": "main_window",
"preload": {
"js": "./preload.js"
}
}
]
}
}
}
]
}
},
"dependencies": {
"electron-squirrel-startup": "1.0.0",
"example-core": "*"
},
"devDependencies": {
"@babel/core": "7.20.5",
"@babel/preset-env": "7.20.2",
"@babel/preset-react": "7.18.6",
"@electron-forge/cli": "6.0.4",
"@electron-forge/maker-squirrel": "6.0.4",
"@electron-forge/plugin-webpack": "6.0.4",
"babel-loader": "9.1.0",
"copy-webpack-plugin": "11.0.0",
"cross-env": "7.0.3",
"css-loader": "6.7.2",
"electron": "22.0.0",
"style-loader": "3.3.1",
"svg-sprite-loader": "6.0.11",
"svgo": "3.0.2",
"svgo-loader": "3.0.3",
"webpack": "5.75.0",
"webpack-cli": "5.0.1",
"webpack-dev-server": "4.11.1"
}
}
{
"name": "example-core",
"version": "0.1.0",
"private": true,
"dependencies": {
"core-js": "3.26.1",
"prop-types": "15.8.1",
"regenerator-runtime": "0.13.11",
...etc...
}
} |
Still seeing issues on npm 8.11.0 with workspaces |
I'm a bit late but i have found a solution you can use |
electron-forge DOES support npm workspaces, judging by its code (their is upwards traversal to monorepo root). In my case, I had a faulty |
Electron Forge doesn't work with npm workspaces. See: #53 And: electron/forge#2306 And: npm/cli#7029 And: npm/rfcs#287 This gets the app working when packaged.
I also had this happen to me using The solution was to delete the |
For me, the issue was resolved when using the |
I come back to my previous comment, webpack-typescript setup was not much better. This solution worked for a while until I got the following error
I solved this by updating the
Which seems to bundle the app properly. Can't wait for |
Preflight Checklist
Issue Details
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: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
)Additional Information
The text was updated successfully, but these errors were encountered: