question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isElectronApp is true but remote is null

See original GitHub issue

I tried the workarounds here: https://github.com/ThorstenHans/ngx-electron/issues/32

With:

  win = new BrowserWindow({ width: 950, height: 555, backgroundColor: "#ffffff",
    acceptFirstMouse: true,
    webPreferences: {
      nodeIntegration: true,
      nodeIntegrationInWorker: true,
      backgroundThrottling: false
    }
  });

Somehow nodeIntegration: true seems to go ignored for me, I’m trying to use the remote module to require fs but remote keeps coming back as null. Spent all day trying all different kinds of workarounds, but nothing worked. I have "@angular-builders/custom-webpack": "^9.2.0" and "electron-builder": "^22.7.0":

const webpack = require('webpack')

module.exports = {
  node: {
      crypto: false,
      path: true,
      os: true,
      stream: true,
      buffer: false
  },
  plugins: [
         new webpack.DefinePlugin({
             'process.env.NODE_ENV': JSON.stringify('production')
         })
     ]

}

I also tried adding:

  target: "node-webkit",

It compiles and packages the app but throws require is not defined before the app gets loaded, I guess this only worked in an older version of webpack.

angular.json has: "builder": "@angular-builders/custom-webpack:browser",

If I try to require('electron').remote or window.require('electron').remote in the console after the unmodified app has loaded (no ngx-electron inside), then I just get require is not defined as well.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:18

github_iconTop GitHub Comments

13reactions
billygerhardcommented, Mar 17, 2021

Its because of the new security options they add as electron gets updated more, my current webPreferences for my main window I know you need on electron 12 are

webPreferences: {
      enableRemoteModule: true,
      contextIsolation: false,
}
5reactions
StationedInTheFieldcommented, Aug 31, 2020

Try:

webPreferences: {
      nodeIntegration: true,
      nodeIntegrationInWorker: true,
      backgroundThrottling: false,
      enableRemoteModule: true
    }

Among other things that’s one thing I changed, you can also keep your eyes on https://github.com/QuestNetwork/quest-messenger-js - I still have a little libp2p pubsub issue (ipfs/js-ipfs issues/3249), but once that’s solved and the demo works, I’ll commit it and it has remote working now (using it to require ‘fs’ so that I can store config, message history, etc)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · ThorstenHans/ngx-electron · GitHub
isElectronApp is true but remote is null. #52 opened Aug 28, 2020 by StationedInTheField · 18 · Integration with ngZone for callbacks from...
Read more >
Electron.remote is undefined even enableRemoteModule is true
Here are the changes in the API. I am sure this helps you figure out the new changes since the remote module is...
Read more >
Breaking Changes | Electron
Planned Breaking API Changes (14.0)​. Removed: remote module​. The remote module was deprecated in Electron 12, and will be removed in Electron 14....
Read more >
Angular 5 Electron Tutorial
IpcRenderer - Electron IpcRenderer; remote: Electron. ... NativeImage - Electron's NativeImage API; isElectronApp: boolean - Indicates if ...
Read more >
A Simple angular Wrapper for Electron's Renderer API - Morioh
If your app is not running inside electron, all getters will return NULL instead. ... NativeImage - Electron's NativeImage API; isElectronApp: boolean ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found