Process not defined while nodeIntegration is set

my index.js file for electron application

const { app, BrowserWindow } = require('electron');

function createWindow () {
  const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true
    }
  })

  win.loadFile('index.html')
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow()
  }
})

Index.html file

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Hello World!</title>
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
</head>
<body style="background: white;">
    <h1>Hello World!</h1>
    <p>
        We are using node <script>document.write(process.versions.node)</script>,
        Chrome <script>document.write(process.versions.chrome)</script>,
        and Electron <script>document.write(process.versions.electron)</script>.
    </p>
</body>
</html>

the error i am getting in console

Uncaught ReferenceError: process is not defined
    at index.html:11

2 thoughts on “Process not defined while nodeIntegration is set

  1. In latest commit 186301e isolation has been enabled by defualt. That change broke tutorial in official docs. In webPreferences you should disable context isolation to make node integration working again.
    webPreferences: { nodeIntegration: true, contextIsolation: false }
    It’s temporary fix, we should wait for official announcement.