Install React-Devtool
TypeError: BrowserWindow.addDevToolsExtension is not a function
Thank you for taking the time to report this issue and helping to make Electron better.
Please provide a standalone test that a tester could run to reproduce the issue. This makes fixing issues go more smoothly: not only does it ensure the right thing is tested, but it also prevents triage from bottlenecking on making testers write new tests for each new issue.
I'm setting the more-information-needed label for the above reasons. After you've responded, please @ me in a followup comment.
Thanks in advance! Your help is appreciated.
@MarshallOfSound
I Don't know if you need the snippet in main.js ,But here it is
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
const scraper = require('./scraper.js');
const helpers = require('./electron/helpers.js');
const windowStateKeeper = require('electron-window-state');
const { autoUpdater } = require("electron-updater");
require('v8-compile-cache');
// for nodemon
process.env.IS_DEV ? require('electron-reload') : null;
// disable security warning
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
// Application already running, so we close now
if (!app.requestSingleInstanceLock()) {
app.quit()
}
app.removeAllListeners('ready');
let mainWindow
function createWindow() {
// check for uppdate
autoUpdater.checkForUpdatesAndNotify();
// Load the previous state with fallback to defaults
let mainWindowState = windowStateKeeper({
defaultWidth: 1100,
defaultHeight: 600
});
mainWindow = new BrowserWindow({
'x': mainWindowState.x,
'y': mainWindowState.y,
'width': mainWindowState.width,
'height': mainWindowState.height,
minWidth: 1100,
minHeight: 500,
backgroundColor: '#121212',
frame: false,
icon: __dirname + '../build/icon.png',
webPreferences: {
webSecurity: false,
nodeIntegration: true,
webviewTag: true
},
});
// Let us register listeners on the window, so we can update the state
// automatically (the listeners will be removed when the window is closed)
// and restore the maximized or full screen state
mainWindowState.manage(mainWindow);
// http://localhost:3000
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '../build/index.html'),
protocol: 'file:',
slashes: true,
});
mainWindow.loadURL(startUrl);
// in dev mode
if (process.env.ELECTRON_START_URL) {
// open devTools
mainWindow.webContents.openDevTools({ mode: 'undocked' });
}
// in build mode
if (process.env.IS_DEV) {
// close menubar
mainWindow.setMenuBarVisibility(false);
}
//clear session + cookies on start to avoid blocking requests
mainWindow.on('closed', () => {
mainWindow = null
});
mainWindow.webContents.on('new-window', function (e, url) {
e.preventDefault();
})
// Add React Devtool
if (app.isReady() && process.env.ELECTRON_START_URL) {
console.log('___INSTALL React Devtool_____')
BrowserWindow.addDevToolsExtension("./extensions/react")
.then(name => console.log('INSTALLING', name))
.catch(err => console.log('Install React-Devtool err', err));
}
}
app.setAppUserModelId('com.MyMovies.app');
app.on('ready', createWindow);
app.on('window-all-closed', () => {
app.quit();
})
Devtron, React, and Redux extensions all fail to install in Browser windows. If anyone knows a workaround, would love to hear.
[electron] Added Extension: React Developer Tools
[electron] Added Extension: Redux DevTools
[electron] [41948:0228/141801.424392:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read[electron] [41948:0228/141801.424392:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'panels' of undefined", source: chrome-extension://redux-devtools/js/devtools.bundle.js (1)
[electron] [41948:0228/141801.512131:ERROR:CONSOLE(40)] "Uncaught TypeError: Cannot read property 'inspectedWindow' of undefined", source: chrome-extension://react-developer-tools/build/main.js (40)
[electron] Unable to create basic Accelerated OpenGL renderer.
[electron] Unable to create basic Accelerated OpenGL renderer.
[electron] Core Image is now using the software OpenGL renderer. This will be slow.
@stevenroussey-privicy We are able to install react and redux extensions in our apps via the package electron-devtools-installer made by @MarshallOfSound (thanks to him 🙏) but devtools just don't show up sometimes with same kind of error...
[35280:0324/122320.140:ERROR:CONSOLE(1)] "Uncaught TypeError: Cannot read property 'panels' of undefined", source: chrome-extension://redux-devtools/js/devtools.bundle.js (1)
[35280:0324/122320.233:ERROR:CONSOLE(40)] "Uncaught TypeError: Cannot read property 'inspectedWindow' of undefined", source: chrome-extension://react-developer-tools/build/main.js (40)
It feels like extension tabs are created after extensions are loaded in BrowserWindow. The only error i'm catching in backend is related to chrome storage but probably not the cause of the problem.
Exception has occurred: Error
Error: ENOENT: no such file or directory, open "\AppData\Roaming\AppName\Chrome Storage\redux-devtools-sync.json"
We are opening devtools on the event did-frame-finish-load
win.webContents.on('did-frame-finish-load', () => {
win.webContents.openDevTools();
});
We use the same installer method. It installs fine, but won't run. Same errors. Even if I open the devtools manually, so it is not a timing issue there.
We use a splash screen window. From what I can tell, it works fine in the first window created, but fails for other windows. Can anyone else verify?
Might be related to https://github.com/electron/electron/issues/23383
Most helpful comment
Devtron, React, and Redux extensions all fail to install in Browser windows. If anyone knows a workaround, would love to hear.