process is not defined even with nodeIntegration: true

  • Electron Version:
    • ^12.0.0
  • Environment:
    • Arch Linux, npm 6.14.11, node v15.10.0
  • Last Known Working Electron version:
    • ^11.0.0

Expected Behavior

<script>document.write(process.versions.node)</script>

should not throw an error

Actual Behavior

Uncaught ReferenceError: process is not defined

To Reproduce

index.js

const electron = require('electron')

function createWindow () {
  if (electron.BrowserWindow.getAllWindows().length) {
    return
  }
  const win = new electron.BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
    }
  })
  win.loadFile('index.html')
  win.openDevTools()
}

electron.app.whenReady().then(createWindow)

index.html

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>.

package.json

{
  "name": "fe",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "electron ./index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "electron": "^12.0.0"
  }
}

it works fine with electron ^11.0.0

1 possible answer(s) on “process is not defined even with nodeIntegration: true