electron: Uncaught ReferenceError: process is not defined
Preflight Checklist
- I have read the Contributing Guidelines for this project.
- I have searched the issue tracker for an issue that matches the one I want to file, without success.
- I agree to follow the Code of Conduct that this project adheres to.
Issue Details
- Electron Version: 5.0.0
- Operating System: Arch Linux
Expected Behavior
I’d expect to access process object in my renderer process
Actual Behavior
Chrome dev tools throw ReferenceError while accessing to process object.
Uncaught ReferenceError: process is not defined
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 26 (2 by maintainers)
@msudgh
nodeIntegrationis turned off by default in5, so you’ll need to enable it via:which we caution against, or add it via preload script.
I needed to use both, using only
contextIsolation: false/nodeIntegration: truedoesn’t fix the issue. This affects the quick start guide as onlynodeIntegration: truewas mentioned there.update your main.js as follows:
Note
contextIsolation: falsenow replacesnodeIntegration: true.Using the quick start (https://www.electronjs.org/docs/tutorial/quick-start), copied exact code, but still doesn’t work 😦
Code:
Error:
Uncaught ReferenceError: process is not definedx 3, because checking Node, Chromium, Electron versionsWhere to add this above code?
If i use both of the nodeIntegration:true and constextIsolation:false it shows up a error which is:
If i turn both of them true it still get the error: process is not defined
@codebytere Thanks. it’d be better to update docs. this functionality existed in previous versions.
Wow. Works like a charm. I would request ElectronJS Team to please update the docs and add this, or totally remove the need to use
contextIsolationwithnodeIntegrationThanks it worked for me, you don’t that how happy now I am thank you very very much…
@msudgh this information was presented both in release notes and in breaking change documentation leading up to and including the stable release 😃
I did resolve it putting contextIsolation to false.
// 1. import electron objects const { app, BrowserWindow } = require(‘electron’);
// 2. reserve a reference to window object let window;
// 3. wait till application started app.on(‘ready’, () => { // 4. create a new window window = new BrowserWindow({ width: 800, height: 600, webPreferences: { nodeIntegration: true, contextIsolation: false } }); // 5. load window content window.loadFile(‘index.html’); });
Thanks for quick help 😃 this solved the issue in the simple sample 😉