MarshallOfSound / electron-devtools-installer

An easy way to ensure Chrome DevTools extensions into Electron
MIT License
1.11k stars 136 forks source link

Uncaught TypeError: Cannot read property 'forEach' of undefined at Object.injectIntoGlobalHook #205

Open Matrixbirds opened 2 years ago

Matrixbirds commented 2 years ago

Hi guys, I m using electron-devtools-installer in my electron apps.

reproduce steps:

  1. integration code in electron main code.
    const installExtension = require("electron-devtools-installer");
    // TODO: replace official package version
    // when writing this code, electron-devtools-installer has not released the latest version
    // Expected version, greater than: v3.1.1
    installExtension
    .default([installExtension.REACT_DEVELOPER_TOOLS], {
        loadExtensionOptions: {
            allowFileAccess: true,
        },
    })
    .catch((err: Error) => console.log("added extension failed", err));
  2. bootstrap main process.

Got Error Uncaught TypeError: Cannot read property 'forEach' of undefined at Object.injectIntoGlobalHook.

Found many solutions about this error is indicating when using old verions react devtools, caused the conflict with react react-refresh/src/ReactFreshRuntime.js

Solutions:

We can see the userData is the folder to save the react-devtools in extensions folder.

  1. find the userData path.
  2. delete extensions folder.
  3. re-install react-devtools by electron-devtools-installer.
Matrixbirds commented 2 years ago

Suggestion:

  1. How to handle notification about old extensions plugin to upgrade the latest version or stable version.
julianmesa-gitkraken commented 2 years ago

@Matrixbirds This PR will download the required devtools: https://github.com/MarshallOfSound/electron-devtools-installer/pull/210 At now chrome version passed to the chrome store is 32, so yo get an old devtools