Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

In main.js I have set nodeIntegration:false for the BrowserWindow, but the app doesn't start, as I get this error in webview's console:

Uncaught ReferenceError: require is not defined

If I remove nodeIntegration:false from main.js, it works, but I don't want to expose node API.

(P.S.: the remote web app pointed by the webview is using jQuery. Maybe a conflict?)

If you remove nodeIntegration : false command like require won't be set.

It seems like you have 2 possibilities :

  • let nodeIntegration: false and deal with it

  • call your js file as if you were in browser : <script src="pathToFile"></script>

  • https://electronjs.org/docs/faq#i-can-not-use-jqueryrequirejsmeteorangularjs-in-electron here they explain what really does nodeIntegration

    For your option#1: I don't know how to deal with it, as it will expose Node API in the web app. For option#2: it doesn't work as it will generate a message "require is not defined" in renderer.js – Fabio Marzocca Dec 2, 2017 at 12:50 then you should use browserify : browserify.org It enables you to use require in js front file. – mJehanno Dec 4, 2017 at 8:14

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.