Closed guizmaii closed 2 years ago
The Webpack plugin modifies the original package.json, setting devDependencies
(as well as dependencies
/optionalDependencies
/peerDependencies
) to an empty object here: https://github.com/electron/forge/blob/1f45e2ca701ec117df932f38e7fe808bdd832e74/packages/plugin/webpack/src/WebpackPlugin.ts#L241-L244
When @doyensec/electronegativity
attempts to read the Electron version from devDependencies
, it finds none, hence the error.
I believe this could be fixed by simply not modifying the original package.json file. While removing dependencies from the distributed package.json can be desirable, plugins shouldn't really introduce any side effects like this one.
This behavior seems to exist just as an additional measure to prevent the whole node_modules directory to be packaged, as described in https://github.com/electron-userland/electron-forge/issues/593#issuecomment-430102069. But since the plugin already ignores anything outside the .webpack directory and does not call npm install
, using the original package.json should be safe enough.
Pre-flight checklist
Electron Forge version
6.0.0-beta.63
Electron version
v18.1.0
Operating system
Ubuntu 20.04.4 / macOS 11.6.5 / Microsoft Windows Server 2022 10.0.20348
Last known working Electron Forge version
No response
Expected behavior
The Electron version must be auto-detected
Actual behavior
I configured the
plugin-electronegativity
in a brand new generated Electron+TS+Wepback project (thanks to https://www.electronforge.io/templates/typescript-+-webpack-template), following the plugin doc: https://www.electronforge.io/config/plugins/electronegativityIn my CI, running on Mac, Windows and Linux, when I run
yarn make
I have the following error:Steps to reproduce
yarn make
Additional information
No response