electron-db icon indicating copy to clipboard operation
electron-db copied to clipboard

fs.existsSync is not a function

Open phillipstemann opened this issue 5 years ago • 4 comments

I get this error when I try to create a table: fs.existsSync is not a function

What do I do wrong?

const db = require('electron-db') db.createTable('tasks', (succ, msg) => { // succ - boolean, tells if the call is successful console.log("Success: " + succ) console.log("Message: " + msg) })

phillipstemann avatar Jul 03 '20 08:07 phillipstemann

I found out it was because I was running it through the front-end, but is there any way I can register it and use it through my front-end? I'm running VueJS in my Electron app.

phillipstemann avatar Jul 03 '20 08:07 phillipstemann

I have the same problem

mRiloB avatar Sep 17 '20 01:09 mRiloB

if your using vue.js you have 2 options option 1: change require to window.require option 2: create a file in the root named vue.config.js and put this inside it module.exports = { pluginOptions: { electronBuilder: { nodeIntegration: true } } }; the reason you get that is because newer electron has node integration at the core disabled, setting it on the browser window is not enough because that only applies if its enabled at the core (which it is not by default) so you either have to use window.require, or the vue.config.js to enable it at the core

otherwise I have no idea for any other frameworks

j-loriault avatar Nov 27 '20 07:11 j-loriault

Thank you SolarIceMedia for that info!

alexiusacademia avatar Nov 28 '20 13:11 alexiusacademia