I was using node-adodb.js to read .mdb files. code :
const db = require('node-adodb')
ipcMain.on('query', (e, p) => {
if (!p) return
appendFileSync('a.log', new Date().getTime() + ' ' + p.table + ' \r\n')
let conn = db.open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=' + p.path)
conn.query('select ID,品种,批号,日期,包重,条码 from ' + p.table  + ' order by ID')
.then(data => {
  e.sender.send('result', data)
  appendFileSync('a.log', data.length + ' ' + p.table + ' \r\n')
 })
 .catch(err => {
   appendFileSync('a.log', JSON.stringify(err) + ' \r\n')
 })
})
part of package.json:
        "vue-router": "^3.1.3",
    "vuex": "^3.1.2"
  },
  "asar": false,
  "extraResources": [
    {
      "from": "./node_modules/node-adodb/lib/adodb.js",
      "to": "adodb.js"
    }
  ],
  "devDependencies": {
    "@vue/cli-plugin-babel": "^4.1.0",
It worked perfectly on runtime, but when I built it and run the exe, I got
Spawn C:\WINDOWS\SysWOW64\cscript.exe error
{"exitMessage":"Uncaught Fatal Exception","exitCode":1}
I had made some changes, but it didn't seem to work changes
versions:
node v12.12.0
[email protected]
[email protected]
[email protected]
so, is there anyone could help me out this problem?
I found a solution.
you have to
import {app} from 'electron'
import ADODB from 'node-adodb';
if (app.isPackaged) { ADODB.PATH = './resources/adodb.js'; }
and in package.json
 "build": {
"extraResources": [
  {
    "from": "./node_modules/node-adodb/lib/adodb.js",
    "to": "adodb.js"
  }
]
To use node-adodb from electron
Following this boilerplate
In my case the above answer didn't worked as is.
in package.json add the following:
"build": {
    ...
    "extraResources": [
      "./assets/**",
      {
        "from": "./node_modules/node-adodb/lib/adodb.js",
        "to": "adodb.js"
      }
    ],
    ...
}
Then, in each file you need adodb:
const ADODB = require("node-adodb");
///It's only needed to change the path in production. Otherwise in dev it won't work. 
///Something like process.env.NODE_ENV === "development" can be used
if (!isAppDebug()) {
  ADODB.PATH = "./resources/adodb.js";
}
Tested with [email protected] and [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With