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-builder does not copy directories named "node_modules" into my application

See original GitHub issue

electron-builder: >= 20.15.2 target: Windows, Mac OS, Linux

Hi everyone,

Since the new solution for copying node_modules (cf. https://github.com/electron-userland/electron-builder/releases/tag/v20.15.2), is not possible anymore to pass node_modules directory in electron package during build.

My electron app follows this structure:

├── dist_electron
|   ├── electron-main
|   ├── electron-renderer
|   └── webapp-bundle
|        ├── dist
|        └──  node_modules
|
├── index.js
├── package.json

My electron-builder config:

config = {
  appId: `AppName`,
  directories: {
    output: 'dist_electron/electron-binaries',
    buildResources: 'src/electron/resources'
  },
  asar: true,
  files: [
    'index.js',
    'dist_electron',
    '!dist_electron/electron-binaries'
    '!node_modules',
    'package.json',
  ]
  ...
}

I don’t need to electron-builder copies node_modules from my package.json dependencies.

My bundles are compile with webpack and for my webapp-bundle I need to add a node_modules directory with uncompilable modules.

Before electron-builder 20.15.2 it’s was possible to copy directories named “node_modules”.

So my question is: How can I copy children directories named ‘node_modules’ into my application? I don’t find any option or other informations.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
AndriiMelnikkcommented, Jan 22, 2022

It worked for me to add this to package.json:

“build”: { “includeSubNodeModules”: true }

1reaction
Timmmmcommented, May 20, 2020

I guess you guys are all talking about this annoying feature:

package.json and **/node_modules/**/* is added to your custom [files entry] in any case.

Pretty annoying! I want Electron-builder to only add the entries in files. It seems like Vue’s electron-builder plugin’s solution is to copy package.json into your dist directory, and then run electron-builder there (or pass the --app command line option I guess). Then there is no node_modules directory to copy.

You may want to ditch the Webpack, because there are no HTTP requests running between hard drive and Electron binary, and all assets and code are already bundled into ASAR archive.

Right but Webpack does more than just bundling Javascript. It can process images, compile Typescript, add mocks, minify Javascript, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron builder not copying my dist/node_modules directory ...
When I launch the application it obviously complains of not finding the node_modules . The docs say there's some default files pattern which...
Read more >
Application Contents - electron-builder
A glob patterns relative to the project directory, when specified, copy the file or directory with matching names directly into the app's resources...
Read more >
Options | electron-packager
Functions to be called after your app directory has been copied to a temporary directory. Note: afterCopy will not be called if the...
Read more >
app/node_modules/electron-packager - GitLab
Electron desktop application allowing users to import images of curves to extract data. Based on Rohatgi, Ankit (May 2016). WebPlotDigitizer (Version 3.10) ...
Read more >
paulcbetts/electron-packager NPM
Be careful not to include node_modules you don't want into your final app. electron-packager , electron-prebuilt and .git will be ignored by default....
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