sqwk
sqwk

Reputation: 2699

Node require() inside Angular 2 App with Electron

I am trying to use electron's remote to set application menus etc. However, the angular polyfills catch the require('electron).remote and log require is not a function to the console. (Which makes sense as it would not be a function inside a normal web environment.)

Is there a way to prevent this?

Upvotes: 2

Views: 793

Answers (1)

sqwk
sqwk

Reputation: 2699

According to the electron docs, the require collision can be overridden using this code before the angular and systemjs polyfills:

<script>
    window.nodeRequire = require;
    delete window.require;
    delete window.exports;
    delete window.module;
</script>

More info here: http://electron.atom.io/docs/v0.37.3/faq/electron-faq/

Upvotes: 3

Related Questions