Trying To Use Electron With NuxtJs

Viewed 514

I've followed these steps to create a nuxt/electron project, And it worked perfectly... But once I tried to use any of electron's modules like the ipcRenderer in a component or page, it doesn't work. The problem is at:

const { ipcRenderer } = require('electron')

I tried running the above code snippet and I got the following error:

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\Users\DELL\Programming\JavaScript\Electronjs\create-nuxt-electron-app\node_modules\electron'

I've turned "nodeIntegration" on (although I prefer not), And it's still not working.

Hope someone who has done this before can help

1 Answers

I also had the same issue. I'he tried everything suggested, changed webpack config target to electron-renderer , used const {ipcRenderer} = eval('require')('electron') , even added preload.js` to my app and in preload.js added this piece of code:

window.ipcRenderer = require('electron').ipcRenderer;

but still in page.vue couldn't access ipcRenderer . So I changed my boilerplate to electron-nuxt and it works fine.

Related