How do I include the node_modules in electron-forge webpack?
Asked Answered
N

0

8

The @vercel/webpack-asset-relocator-loader works in some modules, and does not work in some. In cases that it doesn't work, I have to use the externals config as stated in the electron-forge docs here.

If the asset relocator loader does not work for your native module, you may want to consider using the externals configuration

So what ended up happening is me putting the modules in the externals config like so:

// webpack.main.config.js

module.exports = {
  // other webpack configs
  externals: {
    'active-win': 'commonjs2 active-win',
    iohook: 'commonjs2 iohook',
    'screenshot-desktop': 'commonjs2 screenshot-desktop',
  },
};

What this does is, it will search the node_modules folder whenever those modules are used. This works in development but once the app is packaged, the node_modules folder is empty.

I tried to use @timfish/forge-externals-plugin library but it doesn't work on some modules that I use.

So how do I make it such that the node_modules folder is included in the packaged app? I'm not sure if this is an electron config or webpack config or both. Thanks...

Neckpiece answered 13/4, 2022 at 9:21 Comment(4)
Hi, did you ever find the solution to this?Mollie
Either of you have any luck? I too have the same issue with serialport moduleHobby
Did anyone find the solution to this problem? Struggling to solve this problem for a week?Piccard
I am stuck in a similar issue as well. Any luck with this?Rebuild

© 2022 - 2024 — McMap. All rights reserved.