Having Trouble Loading Vue Devtools in Vue Electron Builder

I'm encountering an issue with loading Vue Devtools in my Electron application integrated with Vue. This is my first time working with this combination, and I suspect there might be a dependency problem causing the Devtools not to load within the Electron app window.

Although I've checked out this Github issue, I have newer versions of Electron and vue-cli-plugin-electron installed with the latest code updates mentioned.

I also attempted the following snippet (sourced from here):

win.loadURL(process.env.WEBPACK_DEV_SERVER_URL).then(() => {
  if (!process.env.IS_TEST) {
    setTimeout(() => win.webContents.openDevTools(), 5555)
  }
})

Unfortunately, using that code snippet resulted in breaking everything.

One more thing I tried was running vue invoke electron-builder to regenerate the configuration, as suggested in the documentation.

However, the issue persists. Could someone please review my setup and point out any obvious mistakes?

This excerpt shows part of my package.json:

 [JSON content here]

And below is my background.js file:

 [JavaScript content here]

Answer №1

The official release of Vue DevTools is not yet compatible with Vue 3.

To work around this issue, you will need to install the Vue DevTools Beta instead.

Make the following change:

await installExtension({
  id: 'ljjemllljcmogpfapbkkighbhhppjdbg',
  electron: '>=1.2.1'
})

For more details, check out the discussion here.

UPDATE

You can now simply use the VUEJS3_DEVTOOLS constant like this:

await installExtension(VUEJS3_DEVTOOLS);

Answer №2

Instead of using timeouts, it's recommended to wait for the dom-ready event. This approach is likely to ensure everything works smoothly.

Check out this related fix for Redux devtools.

const {
    app,
    BrowserWindow,
} = require("electron");
const {
    default: installExtension,
    VUEJS_DEVTOOLS
} = require("electron-devtools-installer");
const isDev = process.env.NODE_ENV === "development";

// Keep a global reference of the window object to prevent automatic closure
let win;

async function createWindow() {

    // Create the browser window
    win = new BrowserWindow({
        width: 800,
        height: 600,
        title: "MyAppTitle",
        webPreferences: {
            devTools: isDev
        }
    });

    // Load the app
    win.loadURL("index.html");

    // Perform actions only in development mode
    if (isDev) {

        // Install Vue.js devtools and open DevTools when DOM is ready
        win.webContents.once("dom-ready", async () => {
            await installExtension([VUEJS_DEVTOOLS])
                .then((name) => console.log(`Added Extension:  ${name}`))
                .catch((err) => console.log("An error occurred: ", err))
                .finally(() => {
                    win.webContents.openDevTools();
                });
        });
    }

    // Handle window closed event
    win.on("closed", () => {
        // Dereference the window object to prevent memory leaks
        win = null;
    });
}

// Called when Electron has finished initialization and can create browser windows
app.on("ready", createWindow);

// Quit when all windows are closed
app.on("window-all-closed", () => {
    // On macOS, keep the application active until explicitly quit
    if (process.platform !== "darwin") {
        app.quit();
    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best method for capturing the line delimiter character(s) in a manner that is not dependent on the platform being

When using the regular expression /^\S+\s*$/m.exec("a\nb\n")[0], it only returns "a" without including the line delimiter, even though \s should match \n. After some experimentation, I discovered that modifying the expression ...

What factors could potentially cause Internet Explorer to fail in processing conditional comments effectively?

I am currently developing JSP pages with Tomcat and I need to ensure compatibility with IE 7, as requested by the client, along with Firefox and Chrome. Despite including both sets of code in my program, it seems to work perfectly fine for browsers other ...

Vue parent component not receiving events properly

Referring to these sources: Forum Post Stack Overflow Question In my project, I am utilizing: CodeSandbox Example The setup involves the parent component listening for events emitted by a child component: mounted() { this.$on("edit-category& ...

Is the length of a complex match in Angular JS ng-if and ng-repeat greater than a specified value?

In my code, there is an ng-repeat that generates a table based on one loop, and within each row, another cell is populated based on a different loop: <tbody> <tr ng-repeat="r in roles | limitTo: 30"> <td>{{r.name}}</td> ...

Sorting WordPress entries by nearby locations

I have WordPress posts that are being displayed on a Google Map. The posts are pulling data from a custom post field that contains the latlng value, where latitude and longitude are combined into one. Additionally, the map shows the user's location u ...

Using AngularJS to Nest ng-view within ng-repeat

I have a collection of items. Each item has buttons to display its details and comments within this ng-view section. It is necessary for the user to view all available product details on one page, for example. Below is the HTML list: <div ng-controll ...

JSON data not displaying correctly in bootstrap table

I've been grappling with this issue for hours now, but I'm struggling to get my bootstrap table populated correctly. Here's the snippet of my HTML: <html> <head> <link rel="stylesheet" href="https://code.jquery.com/ui/1.1 ...

What could be the reason for the container div's height not being properly refreshed?

When adding elements to a container div with an initial height of 'auto', I assumed that the height would adjust based on the children elements added. However, this is not happening. Can anyone assist me in ensuring that the container div's ...

Is there a way to modify or add to the response object's methods in Express and Node.js?

When using middleware in Express, the framework passes both a res and a req object. These objects enhance the built-in ones from http.ServerResponse and http.ClientRequest respectively. I am curious about the possibility of overriding or extending methods ...

bulk purchase discount with HTML/JavaScript/PHP

I am looking to add a slider feature to my "Prices" page in order to provide customers with an instant quote based on the quantity they select. The slider should range from 1 to 500 or even up to 1000, but having an input box for customers to enter the qu ...

Navigate through intricate JSON structure

Struggling with a highly complex JSON object, I am trying to list out all the properties and keys exactly as they are. While I have grasped the concept, I am having trouble with the execution. Every time the object contains another object, I need to call ...

The Catcomplete widget malfunctioned after the update of jQuery UI from version 1.8 to 1.12

I've encountered an issue with my code after updating to jQuery UI 1.12 var currentCategory = ""; $.widget("custom.catcomplete", $.ui.autocomplete, { _renderMenu: function (ul, items) { var self = this; $.each( ...

Displaying an image within a textarea using JS and CSS

Could someone help me create a form with textareas that have small images on them? I want clicking on the image to call a function fx(). Can anyone code this for me using JavaScript/jQuery/CSS? In the image below, clicking on "GO" will call Fx() I attemp ...

The implementation of a custom event for jQuery rows is not functioning as expected

I need assistance with jQuery code to add click events only to columns in a row that have text in the first column. Specifically, I want to hide rows containing "1/" in the first column when clicked on for the first row. <table class="results"> < ...

The Material UI component successfully loads the options data list from the server response, however, it fails to return the selected value when an option

My goal is to dynamically populate my country and province select component based on server response data. The process begins with the user selecting a country, which triggers a request to the server using the selected country's id. The server respond ...

What is preventing me from installing socket.io?

I keep seeing an error in the console, what could be causing this? npm ERR! code 1 npm ERR! path E:\full-stack\proshop-2\socket\node_modules\utf-8-validate npm ERR! command failed npm ERR! command C:\WINDOWS\system32&bso ...

sinon: Techniques for stubbing an entire class as opposed to singular methods

I am faced with a situation where I have a class that instantiates another class in my test. My goal is to stub out the entire second class, ensuring that its constructor is never invoked. Consider the following scenario: Test.js class Test { construct ...

What could be causing the bootstrap 4 col-md-3 block to shrink when using position fixed?

When working with Bootstrap 4, I encountered an issue where changing the block position from relative to fixed using a script caused the block to decrease in size. The script I used includes a .sticky class: .sticky { position: fixed !important; top: ...

Encountering an "Unspecified Reference Error" while attempting to retrieve data from an API in your

I've been attempting to utilize a mock API from in order to fetch data for my Next.js application. However, I am consistently encountering an undefined reference error, despite following the code snippet provided in the official Next.js documentation ...

Changing the value of a variable after iterating through an array in JavaScript

I'm just getting started with programming and teaching myself. I'm struggling to grasp how to update a variable by iterating through an array. Here's an array containing the best pies, each with its own price: [blueberry, strawberry, pumpk ...