How to access require in dojo/require.js apps?


currently i carry it by tracking it as variable in window[‘eRequire’], done in the renderer code.

however, the latest electron detector is “window.process.*” but i can’t find Electron’s require anywhere in there.

so what would be the safe path to get require :slight_smile: ?

thanks a lot.

ps: these things happen if your app needs to run outside of electron


It’s in the FAQ:

I can not use jQuery/RequireJS/Meteor/AngularJS in Electron.

Due to the Node.js integration of Electron, there are some extra symbols
inserted into the DOM like module, exports, require. This causes problems
for some libraries since they want to insert the symbols with the same names.

To solve this, you can turn off node integration in Electron:

// In the main process.
let win = new BrowserWindow({
  webPreferences: {
    nodeIntegration: false

But if you want to keep the abilities of using Node.js and Electron APIs, you
have to rename the symbols in the page before including other libraries:

window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
<script type="text/javascript" src="jquery.js"></script>


thanks, but no, dont want to disable anything


You wouldn’t be disabling it, just holding onto it under a different name. Although, I suppose that’s what you’re referring to in your first post?

Anyhow, you need to access Electron’s require before calling any other scripts that might override it.


ok, thanks. i understand. so at the end i will have to trace it just as described in my first post, or something similar as described later.

i just hoped, Electron keeps somewhere else its require pointer but ok, can live with that.