Code Monkey home page Code Monkey logo

Comments (4)

bendemboski avatar bendemboski commented on June 15, 2024

Maybe you haven't enabled nodeIntegration? You'd need to set it when creating your BrowserWindow in index.js -- see https://www.electronjs.org/docs/api/browser-window for the specific usage/syntax.

from ember-electron.

RobbieTheWagner avatar RobbieTheWagner commented on June 15, 2024

Does just importing it work? I do this:

    if (typeof requireNode !== 'undefined') {
      let { ipcRenderer } = requireNode('electron');

from ember-electron.

tomisarobot avatar tomisarobot commented on June 15, 2024

Ahh, you're right.

I had tried that at some point but I think I did {nodeIntegration:true} instead of {webPreferences:{nodeIntegration:true}}, so that tripped me up.

From the docs at usage, I understood that node integration was built in.

Mentioning "when using nodeIntegration" might make that more clear? The docs lean towards folks that kind of already know how a lot of this stuff works, so maybe that's ok.

Thanks for the help Ben!

In case others hit this issue, this is what I changed.

I added the webPreferences field to BrowserWindow constructor in electron-app/src/index.js:

  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true
    }
  });

and then I also had to use this import syntax instead:

// import ipcRenderer from 'electron';
const { ipcRenderer } = requireNode('electron');

from ember-electron.

bendemboski avatar bendemboski commented on June 15, 2024

You bet! And that's a good suggestion about mentioning nodeIntegration -- I just opened a #668 to add it to the documentation.

from ember-electron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.