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.

app.electron, app.webContents, etc.. undefined even if nodeIntegration is set to true

See original GitHub issue

Hello,

Thanks for your great work on spectron. I’m trying to setup spectron in my project but even if nodeIntegration is set to true, app.electron and other variables are undefined.

You can reproduce this issue in few minutes:

$ git clone https://github.com/remipassmoilesel/abc-map-2
$ cd abc-map-2
$ npm i
$ npm run test

Here is my test code:

https://github.com/remipassmoilesel/abc-map-2/blob/master/src/tests/api/handlers/MapHandlersTest.ts

And here is the electron init script:

https://github.com/remipassmoilesel/abc-map-2/blob/master/src/electron-main.ts

And if I log the application object we can see that nodeIntegration value is set to false:

app {                                                                
  "host": "127.0.0.1",                                                                                                                                                                                             
  "port": 9515,                                     
  "quitTimeout": 1000,                              
  "startTimeout": 5000,                             
  "waitTimeout": 5000,                                                                                   
  "connectionRetryCount": 10,                                                                            
  "connectionRetryTimeout": 30000,                  
  "nodePath": "/usr/local/bin/node",                                                                     
  "path": "/home/remipassmoilesel/projects/abc-map-2/node_modules/electron/dist/electron",               
  "args": [                                                                                              
    "/home/remipassmoilesel/projects/abc-map-2/dist/electron-main.js"                                    
  ],                                                                                                     
  "chromeDriverArgs": [],                                                                                
  "env": {},                                                                                             
  "workingDirectory": "/home/remipassmoilesel/projects/abc-map-2",                                       
  "requireName": "require",                                                                                                                                                                                        
  "api": {                                                                                               
    "app": "~",                                                                                          
    "requireName": "require",                                                                                                                                                                                      
    "nodeIntegration": false                                                                                                                                                                                       
  },                                        
  ...
   

What can I do to fix this ? Thanks for your help.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:5
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
florin05commented, Oct 16, 2019
1reaction
sindresorhuscommented, Jul 6, 2019

I’m seeing this too just using the examples in the readme.

Read more comments on GitHub >

github_iconTop Results From Across the Web

app.electron, app.webContents, etc.. undefined even if ...
I'm trying to setup spectron in my project but even if nodeIntegration is set to true, app.electron and other variables are undefined.
Read more >
nodeIntegration true ignored? - electron - Stack Overflow
Show activity on this post. I'm trying to use a require directive in my js file attached to an html file. However, I...
Read more >
BrowserWindow | Electron
If it is set to false , can not use BrowserWindow.webContents.openDevTools() to open DevTools. Default is true . nodeIntegration boolean (optional) - Whether ......
Read more >
All of the Documentation | Electron - GitHub Pages
event Event ; webContents WebContents; request Object ... openAtLogin Boolean - true if the app is set to open at login. openAsHidden Boolean...
Read more >
Security, Native Capabilities, and Your Responsibility | Electron
In fact, the most popular Electron apps (Atom, Slack, Visual Studio Code, etc) ... secure remote content without Node integration) – if your...
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