electron: [Bug]: Developer Tools not showing (Electron v23.6.0)

Preflight Checklist

Electron Version

23.6.0

What operating system are you using?

Windows

Operating System Version

Windows 10 Home 22H2 19045.2251

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Developer Tools panel can be opened by user from Menu or can be started automatically when application starts.

Actual Behavior

The Developer Tools not showing at start and can’t be launched from Menu Panel (Toggle Developer Tools).

Testcase Gist URL

No response

Additional Information

The code used with my app:

const { app, BrowserWindow, ipcMain, shell, Notification } = require('electron');
const path = require('path');
const date = require('date-and-time');
const fs = require('fs');
const cmd = require('node-cmd');
const ExcelJS = require('exceljs');
const {getDesktopFolder} = require('platform-folders');


let windowsClosedIf = false;
let values1toIpcRenderer = {};
let sendToIpcRenderer = false;

const createWindow = () => {
  // Create the browser window
	const mainWindow = new BrowserWindow({
		// frame: false,
		autoHideMenuBar: false,
		width: 800,
		height: 650,
		icon: __dirname + '/files/icon.ico',
		webPreferences: {
			nodeIntegration: true,
			contextIsolation: false
		}
	});

	mainWindow.loadFile(path.join(__dirname, 'index.html'));
	
	mainWindow.webContents.openDevTools();	
	// mainWindow.webContents.setDevToolsWebContents(devtools.webContents);
  	// mainWindow.webContents.openDevTools({ mode: 'detach' });
		
	setInterval(() => {
		if (windowsClosedIf == false){
			if (sendToIpcRenderer == true){
				mainWindow.webContents.send('valuesTest', values1toIpcRenderer);
				values1toIpcRenderer = {};
				sendToIpcRenderer = false;
			}
		}
	},500);
};

// If Electron is ready, create windows
app.on('ready', createWindow);

// If all windows are closed do...
app.on('window-all-closed', () => {
	windowsClosedIf = true;
	app.quit();
});

ipcMain.on('openExcel', function(event) {
	// .
	// .
	// .
});

ipcMain.on('awsde2x', async function(event) {
	// .
	// .
	// .
});

ipcMain.on('valsX2', async function(event, data) {
	// .
	// .
	// .
});

My installed packages: +-- date-and-time@2.4.1 +-- electron-builder@23.6.0 +-- electron@21.3.1 +-- exceljs@4.3.0 +-- fs@0.0.1-security +-- node-cmd@5.0.0 +-- nodemon@2.0.20 +-- path@0.12.7 ±- platform-folders@0.6.0`

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

I got same trouble on 22.1.0 and finally I found a solution. I don’t know this is “right” approach but at least I can use Devtools

    win.on("ready-to-show", () => {
      win.webContents.openDevTools();
    });

The same problem. win.webContents.openDevTools() does nothing. Last known electron version 17 without that problem. Not working with version 22, 23. 24, 25, 26, 27, 28. When openDevTools executing in terminal appears electron errors:

[11182:0115/184841.842398:ERROR:platform_shared_memory_region_posix.cc(217)] Creating shared memory in /dev/shm/.org.chromium.Chromium.goNOaF failed: No such file or directory (2)
[11182:0115/184841.842616:ERROR:platform_shared_memory_region_posix.cc(220)] Unable to access(W_OK|X_OK) /dev/shm: No such file or directory (2)
[11182:0115/184841.842756:FATAL:platform_shared_memory_region_posix.cc(222)] This is frequently caused by incorrect permissions on /dev/shm.  Try 'sudo chmod 1777 /dev/shm' to fix.

I solved the problem by removing app.commandLine.appendSwitch(‘no-sandbox’)