Vue-cli-plugin-electron-builder: Can't access "electron" through the renderer process

Created on 22 Oct 2020  路  2Comments  路  Source: nklayman/vue-cli-plugin-electron-builder

I tried creating a project using:

vue create electron-test
cd electron-test
vue add electron-builder
(selecting ^9.0.0)

Then, in the App.vue:

import HelloWorld from './components/HelloWorld.vue';
import { shell } from "electron";

export default {
  name: 'App',
  components: {
    HelloWorld
  },
  data() {
    return {
      shell
    };
  }
};

However, Chrome DevTools is showing:
electron_2020-10-22_08-25-43

I know this is a bug in the plugin since I followed the quick start tutorial, during which I used Electron 10, and I successfully imported shell in the renderer process.

Most helpful comment

Add

module.exports = {
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true
    }
  }
}

to your vue.config.js, see: https://github.com/electron/electron/issues/24005#issuecomment-643705734

All 2 comments

Add

module.exports = {
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true
    }
  }
}

to your vue.config.js, see: https://github.com/electron/electron/issues/24005#issuecomment-643705734

That surprisingly worked, thanks!
Turns out I only needed this snippet.
I could still do

import { shell } from "electron";
Was this page helpful?
0 / 5 - 0 ratings

Related issues

getflourish picture getflourish  路  5Comments

Timibadass picture Timibadass  路  6Comments

nickduskey picture nickduskey  路  3Comments

HarlanGitHub picture HarlanGitHub  路  4Comments

itsMikeLowrey picture itsMikeLowrey  路  5Comments