electron / forge

:electron: A complete tool for building and publishing Electron applications
https://electronforge.io
MIT License
6.48k stars 514 forks source link

Require module doesn't work at built application #3737

Open keenoptical opened 3 weeks ago

keenoptical commented 3 weeks ago

Pre-flight checklist

Electron Forge version

7.5.0

Electron version

32.2.0

Operating system

Windows 11

Last known working Electron Forge version

-

Expected behavior

Require module works as usual.

Actual behavior

Require module throws error "Module not found" at built application.

Steps to reproduce

I am trying to require module from node_modules using standart node module api: const neededModule = require("agora-electron-sdk"). Locally everything works correctly, but after building application using electron-forge make i've got these error: Image Such behavior appears both at main.js and preload.js. Here is fragment of my BrowserWindow config which probably shall allow using node modules in renderer context:

  webPreferences: {
      preload: path.join(__dirname, 'preload.js'),
      nodeIntegration: true,
      contextIsolation: false,
      nodeIntegrationInWorker: true,
   },

How to make require module work at already built application if there is special need to add non-esm module at project?

Additional information

No response

acgrid commented 1 week ago

Maybe introduced as 7.5.0, 7.4.0 worked as expected. I checked the built app.asar, no node_modules folder is found.