Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DevTools extention does not load #915

Closed
TheAutomaTom opened this issue Mar 15, 2023 · 11 comments
Closed

DevTools extention does not load #915

TheAutomaTom opened this issue Mar 15, 2023 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@TheAutomaTom
Copy link

TheAutomaTom commented Mar 15, 2023

Describe the bug
electron-devtools-installer's VUEJS3_DEVTOOLS extension does not load.

To Reproduce
Steps to reproduce the behavior:

  1. Fork and clone the repo.
  2. Uncomment lines 48 to 57 of packages\main\src\index.ts
  3. Add requirements, npm i electron-devtools-installer (also tried as dev dependency)
  4. Download packages, npm i
  5. ctrl+shift+P => Reload developer window to remove error at import statement.
  6. Debug in dev mode, either by F5 or npm run watch
  7. See error in terminal, "Failed install extension: TypeError: installExtension is not a function."

Expected behavior
No error reported in the terminal, and devtools would display a "Vue" tab.

Additional context
I notice that going to the definition of electron-devtools-installer only shows a function named intall(). Changing the call to this didn't solve the problem. The packages' docs say to use installExtention(). I have not tried with any other dev tools, as I only use Vue 3.

I was installing electron-devtools-installer ^3.2.0, but after seeing v3.2.0 is labelled "build: failing," I rolled back to versions 3.1 and 3.0, with no positive result.

@TheAutomaTom TheAutomaTom added the bug Something isn't working label Mar 15, 2023
@Tanimodori
Copy link
Contributor

This is happening on my side. I change the installer to use a local one, and adjusted the show code of devtools. Now I get 95% of success chance of it.

@TheAutomaTom
Copy link
Author

@Tanimodori are you describe "not using the extension?" I notice v3.2.0 has been released for 2 years. This is really my first experience with electron or that package... I wonder where the fault is?

@TheAutomaTom TheAutomaTom closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2023
@TheAutomaTom
Copy link
Author

Yup, no extension works fine! Electron's docs outline an easy path to success. I'm sure the extension adds some convenience... but it's not working.

@cawa-93
Copy link
Owner

cawa-93 commented Mar 17, 2023

This should work. module.default.default 🤯🤔

if (import.meta.env.DEV) {
  app
    .whenReady()
    .then(() => import('electron-devtools-installer'))
    .then(module => {
      console.log(module);
      return module.default.default(module.default.VUEJS3_DEVTOOLS, {
        loadExtensionOptions: {
          allowFileAccess: true,
        },
      });
    })
    .catch(e => console.error('Failed install extension:', e));
}

Same issue as here, I assume

@Tanimodori
Copy link
Contributor

@cawa-93 For that auto updater issue, as long as you set esModuleInterop to true in tsconfig, it will be resolved.

@cawa-93
Copy link
Owner

cawa-93 commented Mar 17, 2023

@cawa-93 For that auto updater issue, as long as you set esModuleInterop to true in tsconfig, it will be resolved.

But it did't fixed this issue. 🤔 Ok. Maybe auto updater issue is't relevant to this

cawa-93 added a commit that referenced this issue Mar 17, 2023
@cawa-93 cawa-93 closed this as completed Mar 17, 2023
@Tanimodori
Copy link
Contributor

I personally loads the extension from locally installed Chrome extension dir:

if (import.meta.env.DEV) {
  app.whenReady().then(() => {
    if (!process.env['APPDATA']) {
      throw new Error('Could not load extensions from local');
    }
    const extPath = join(
      process.env['APPDATA'],
      '../Local/Google/Chrome/User Data/Default/Extensions/nhdogjmejiglipccpnnnanhbledajbpd',
    );
    const extVersions = readdirSync(extPath);
    const VUE_DEVTOOLS_PATH = join(extPath, extVersions[0])
    session.defaultSession.loadExtension(VUE_DEVTOOLS_PATH, {
      allowFileAccess: true,
    });
  });
}

More info: vuejs/devtools#2035 (comment)

@acurrieclark
Copy link

I found the same issue when I was installing Redux Dev Tools. For some reason the default import from electron-devtools-installer wasn't working as I expected. I had to reference the default directly:

import installExtension, { REDUX_DEVTOOLS } from "electron-devtools-installer";

app.whenReady().then(() => {
  ((installExtension as any).default as typeof installExtension)(REDUX_DEVTOOLS)
    .then(name => console.log(`Added Extension:  ${name}`))
    .catch(err => console.log("An error occurred: ", err));
});

@Tanimodori
Copy link
Contributor

@acurrieclark Your issue is a duplicate of vitejs/vite#2139, which is caused by diffrent default export path between commonJs and ESM. You can turn on TS esModuleInterop flag to automatically do the default export unwrap for you.

@acurrieclark
Copy link

@Tanimodori thats really good to know! Thank you

@FlashAndromeda
Copy link

Hi! I managed to solve this issue by using the solution found in this comment. Turns out you have to manually set the extension ID. I still however get the error about the extension working on manifest v2 and not v3. Vue devtools has a working manifest v3 fork however I don't know how to use it here. Would be nice to update the template with a fix for this and using manifest v3 fork.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants