Node-adodb got 'Spawn C:\WINDOWS\SysWOW64\cscript.exe error' after electron-build

I am having an issue with my code that uses node-adodb.js to read .mdb files. When I run the code on runtime, it works perfectly, but when I build it and run the exe, I get the following error:

Spawn C:\WINDOWS\SysWOW64\cscript.exe error
{“exitMessage”:“Uncaught Fatal Exception”,“exitCode”:1}

I have made some changes, but they do not seem to work (changes).

My versions are as follows:

  • node v12.12.0
  • electron-builder@21.2.0
  • electron@6.1.7
  • vue-cli-plugin-electron-builder@1.4.4

The code used is:

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')

 })

})

The package.json includes:

        "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",

Is there anyone who can help me with this issue?

It seems that the issue is related to the use of node-adodb.js and the cscript.exe process. One possible solution is to add the following lines to the package.json file:

"build": {
    "win": {
      "extraFiles": [
        "./node_modules/node-adodb/**/*"
      ]
    }
  }

This will include all the files from the node-adodb module in the build process.

Additionally, you may need to add the following lines to the main.js file:

const path = require('path')
process.env.PATH = `${process.env.PATH}${path.delimiter}${path.join(__dirname, 'node_modules', 'node-adodb', 'build', 'Release')}`

This will ensure that the cscript.exe process can find the necessary dependencies.