You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
electron-packager unexpectedly copies entire package.json into distribution #1184
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 Packager Version: 15.1.0
Electron Version: v10.1.3
Operating System: darwin 19.6.0 (x64)
Expected Behavior
electron-packager creates a distribution with the minimal package.json required for Electron. As far as I know, it only needs to contain the main field. It should not leak private info about my development setup.
Actual Behavior
electron-packager seems to just copy-paste my entire package.json into the distribution. This contains all kind of unnecessary and private info, such as my devDependencies and scripts. These are never accessed at runtime and so should not be distributed.
👋 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
So here is my awful hacky workaround. It creates a custom afterPrune callback, which modifies the package.json to only include fields necessary for distribution.
I'm going to leave this issue open, as I don't know whether this is the expected or best way to achieve this. It certainly feels like an ugly way to achieve the behavior that I expected.
So here is my awful hacky workaround. It creates a custom afterPrune callback, which modifies the package.json to only include fields necessary for distribution.
I'm going to leave this issue open, as I don't know whether this is the expected or best way to achieve this. It certainly feels like an ugly way to achieve the behavior that I expected.
Activity
welcome commentedon Oct 13, 2020
👋 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
jameshfisher commentedon Oct 13, 2020
So here is my awful hacky workaround. It creates a custom
afterPrunecallback, which modifies thepackage.jsonto only include fields necessary for distribution.I'm going to leave this issue open, as I don't know whether this is the expected or best way to achieve this. It certainly feels like an ugly way to achieve the behavior that I expected.
DenisTis commentedon Oct 28, 2023
Could you please provide more data on where did you add this?
And which command did you use for the build?
feat: add sanitizePackageJson option to strip dev-only package.json f…
feat: add sanitizePackageJson option to strip dev-only package.json f…
electron-npm-package-publisher commentedon Aug 6, 2026
🎉 This issue has been resolved in version 20.2.0 🎉
The release is available on:
Your semantic-release bot 📦🚀