ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

ibm_db odbc_bindings.node not valid Win32 application w/ Node 18.16.0 #920

Closed awharn closed 1 year ago

awharn commented 1 year ago

Steps to Reproduce:

  1. Install ibm_db on Windows with Node 18.16.0 without build tools
  2. Require ibm_db

Output of npm install ibm_db:

C:\Users\WDAGUtilityAccount\test>npm install ibm_db

added 60 packages in 5s

4 packages are looking for funding
  run `npm fund` for details
npm notice
npm notice New minor version of npm available! 9.5.1 -> 9.6.5
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.5
npm notice Run npm install -g npm@9.6.5 to update!
npm notice

Test Script to Reproduce:

npm install ibm_db & node -e "const ibmdb = require('ibm_db')"

Test Script Output:

Error: \\?\C:\Users\WDAGUtilityAccount\test\node_modules\ibm_db\build\Release\odbc_bindings.node is not a valid Win32 application.
\\?\C:\Users\WDAGUtilityAccount\test\node_modules\ibm_db\build\Release\odbc_bindings.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at bindings (C:\Users\WDAGUtilityAccount\test\node_modules\bindings\bindings.js:112:48) {
  code: 'ERR_DLOPEN_FAILED'
}

Other notes: It appears that the downloaded odbc_bindings.node file has different contents between Node versions 18.15.0 and 18.16.0.

bimalkjha commented 1 year ago

@awharn I just tested it using node v18.16.0 and it is working fine. I do not see any issue. Please run below commands from your command prompt and share the complete output below commands here.

cd C:\Users\WDAGUtilityAccount\test\node_modules\ibm_db
npm install > inst.txt
node test\test-basic-test.js

Please attach generated inst.txt file here along with output of test program. Thanks.

awharn commented 1 year ago

@bimalkjha

Regular npm install: inst.txt

Regular npm install with foreground scripts argument: inst2.txt

Output of the commands: output.txt

bimalkjha commented 1 year ago

@awharn Ok. So, now I am able to repro the issue. Workaround is to unzip ibm_db\build.zip file in some other location and then copy build/Release/odbc_bindings.node.18.12.1 file from unzipped dir to ibm_db\build\Release and rename it to odbc_bindings.node. It works for me. I checked both odbc_bindings.node - one that throws error and one which work. Both are exactly same and do not see any difference. So, I am unable to understand the reason for error as of now. I'll keep checking. Thanks.

bimalkjha commented 1 year ago

When I opened the odbc_bindings.node post install and unzipped using 7zip, both has same size but different content. It seems unzipper package of npmjs is corrupting the odbc_bindings.node file post unzip using newer versions of nodejs. Still investigating ...

bmajkut commented 1 month ago

@awharn Ok. So, now I am able to repro the issue. Workaround is to unzip ibm_db\build.zip file in some other location and then copy build/Release/odbc_bindings.node.18.12.1 file from unzipped dir to ibm_db\build\Release and rename it to odbc_bindings.node. It works for me. I checked both odbc_bindings.node - one that throws error and one which work. Both are exactly same and do not see any difference. So, I am unable to understand the reason for error as of now. I'll keep checking. Thanks.

That works for me! Hope it will be fixed