I need to dynamically require a module during runtime and resolve this require manually. Here is what I tried:
BrowserWindow I am requiring a module A like this:
require('./path/to/moduleA.js') which works fine. In the required
moduleA I have another require statement to require
moduleB which I need to resolve manually.
I tried to overwrite the global require function inside of my
BrowserWindow like this:
window.oldRequire = window.require; window.require = src => src === 'moduleB' ? /* resolve manually */ : window.oldRequire;
moduleA I can now call
global.require('moduleB') and my manually resolved module works, but
require('moduleB') doesn’t work. Is there a way to manually resolve modules in electron?