electron / packager

Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
https://npm.im/@electron/packager
BSD 2-Clause "Simplified" License
173 stars 17 forks source link

Does not include other node_modules packages in compiling #1311

Open I2rys opened 2 years ago

I2rys commented 2 years ago

Preflight Checklist

Issue Details

Expected Behavior

It should be able to include node_modules packages in compiling Including express, discordnitro & other NPM packages.

Actual Behavior

After the compiling, run the compiled EXE file and It should return an error Cannot find module 'discordnitro'

To Reproduce

  1. Open CMD and type this command create-electron-app reproduce, Just an example.
  2. cd to the directory & install discordnitro. npm i discordnitro
  3. Import the discordnitro in the file.
  4. cd to src and build it. cd src && electron-packager ./ reproduce --platform=win32 --arch=x64
  5. Run the compiled EXE file and It should return an error Cannot find module 'discordnitro'.

Additional Information

None

welcome[bot] commented 2 years ago

👋 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.

jtkDvlp commented 2 years ago

Hi @I2rys,

I got the same or similar problem. After research I found this change https://github.com/electron/electron-packager/pull/819 since then you have to take care of the pruned node_modules by yourself.

See also the readme "usage"

...Be careful not to include node_modules you don't want into your final app. If you put them in the devDependencies section of package.json, by default none of the modules related to those dependencies will be copied in the app bundles. (This behavior can be turned off with the prune: false API option or --no-prune CLI flag.) In addition, folders like .git and node_modules/.bin will be ignored by default. You can use --ignore to ignore files and folders via a regular expression (not a glob pattern). Examples include --ignore=.gitignore or --ignore=".git(ignore|modules)"...

an prune:false worked for me