Skip to content
New issue

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

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

Already on GitHub? # to your account

Can't call query() in Electron: childProcess.spawn is not a function #461

Open
DPWalther opened this issue Nov 8, 2021 · 1 comment
Open

Comments

@DPWalther
Copy link

DPWalther commented Nov 8, 2021

If i run my code in node it works just fine, but i can't call the query() function if it runs in electron.
Is this a limitation of electron or am i missing something here?

I changed this line in engine.js because in Vue the env variables where not set correctly:

const sysroot = process.env['systemroot'] || process.env['windir'] || "C:\\WINDOWS";

I import and open the connection like this:

const ADODB = require("node-adodb")

const connection = ADODB.open("Driver={Microsoft Access Driver (*.mdb, *.accdb)};Dbq=C:\\Users\\XXXX\\YYYY\\ZZZZ.accdb;Uid=Admin;Pwd=;");

but when i call

console.log(connection.query("SELECT * FROM MSysObjects WHERE Type=1 AND Flags=0"));

it spits out the following error:

log.js?1afd:24 [HMR] Waiting for update signal from WDS...
Home.vue?76f2:16 Promise
spawn.js?d1a4:87 Uncaught (in promise) TypeError: childProcess.spawn is not a function
    at eval (webpack-internal:///./node_modules/node-adodb/lib/spawn.js:87)
    at new Promise (<anonymous>)
    at spawn (webpack-internal:///./node_modules/node-adodb/lib/spawn.js:74)
    at Proxy.exec (webpack-internal:///./node_modules/node-adodb/lib/proxy.js:40)
    at ADODB.query (webpack-internal:///./node_modules/node-adodb/index.js:64)
    at VueComponent.created (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/Home.vue?vue&type=script&lang=js&:17)
    at invokeWithErrorHandling (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1862)
    at callHook (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4229)
    at VueComponent.Vue._init (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:5012)
    at new VueComponent (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:5158)
@DPWalther
Copy link
Author

DPWalther commented Nov 8, 2021

I just found out that this only happens with

console.log(connection.query("SELECT * FROM MSysObjects WHERE Type=1 AND Flags=0"));

this query works fine:

console.log(connection.query("SELECT * FROM Resistors"));

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant