ibmdb / node-ibm_db

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

ibm_db installation fails with error - /bin/sh: node-gyp: command not found #948

Closed orangecoding closed 1 year ago

orangecoding commented 1 year ago

When running npm i, I get this error. node v19.1.0 MacOs latest version.

****************************************
You are downloading a package which includes the Node.js module for IBM DB2/Informix.  The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the node module is installed on your syste.
****************************************

Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/macos64_odbc_cli.tar.gz ...

100.00% | 29943201 bytes downloaded out of 29943201 bytes.

Downloading and extraction of DB2 ODBC CLI Driver completed successfully.

Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
/bin/sh: node-gyp: command not found

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:298:12) {
  code: 127,
  killed: false,
  signal: null,
  cmd: 'node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"'
}
bimalkjha commented 1 year ago

@orangecoding Just run npm install node-gyp and then npm install under ibm_db. It should work fine. Thanks.

bimalkjha commented 1 year ago

@orangecoding I hope your issue got resolved after installing node-gyp package. If so, can we close this issue now? Thanks.

orangecoding commented 1 year ago

hi @bimalkjha sorry I was on vacation. That did not solve the issue at all.

error XXX/node_modules/ibm_db: Command failed.
Exit code: 1
Command: node installer/driverInstall.js
Arguments:
Directory: XXX
Output:
platform = darwin, arch = x64, node.js version = v19.1.0
make version =GNU Make 3.81

Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/macos64_odbc_cli.tar.gz ...

100.00% | 29943201 bytes downloaded out of 29943201 bytes.

Downloading and extraction of DB2 ODBC CLI Driver completed successfully.

Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
/bin/sh: node-gyp: command not found

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:298:12) {
  code: 127,
  killed: false,
  signal: null,
  cmd: 'node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"'
}
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
bimalkjha commented 1 year ago

@orangecoding Please share the complete output of below commands, complete output and not partial as before:

cd XXX
npm ls ibm_db
npm ls node-gyp
gcc -v
python --version
python3 --version
uname -a
npm uninstall ibm_db
npm install node-gyp
npm install ibm_db
npm ls ibm_db
npm ls node-gyp

After looking the complete output of above commands, I can comment further. Thanks.

orangecoding commented 1 year ago

npm ls ibm_db:

cedp@1.0.0 /Users/chriz/dev/
└── ibm_db@3.2.1

npm ls ibm_db:

cedp@1.0.0 /Users/chriz/dev/
└── node-gyp@9.4.0 extraneous

gcc -v

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

python --version

Python 3.11.5

python 3--version

Python 3.11.5

uname -a

Darwin chriz-ibm.local 22.6.0 Darwin Kernel Version 22.6.0: Wed Jul  5 22:21:56 PDT 2023; root:xnu-8796.141.3~6/RELEASE_X86_64 x86_64

npm uninstall ibm_db

npm uninstall ibm_db                                                                                                                                                                  develop removed 208 packages, changed 16 packages, and audited 487 packages in 9s

92 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

npm install node-gyp

npm install node-gyp                                                                                                                                                                develop added 106 packages, and audited 593 packages in 4s

106 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

npm install ibm_db:

npm install ibm_db                                                                                                                                                                  develop ✭ added 34 packages, and audited 627 packages in 46s

107 packages are looking for funding
  run `npm fund` for details

1 moderate severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

npm ls ibm_db

npm ls ibm_db                                                                                                                                                                       develop ✭ cedp@1.0.0 /Users/chriz/dev/
└── ibm_db@3.2.2

npm ls node-gyp

npm ls node-gyp                                                                                                                                                                     develop ✭ cedp@1.0.0 /Users/chriz/dev/
└── node-gyp@9.4.0
orangecoding commented 1 year ago

When running yarn I get:

yarn                                                                                                                                                                              
yarn install v1.22.19
warning ../../../../../package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Users/chriz/dev/node_modules/ibm_db: Command failed.
Exit code: 1
Command: node installer/driverInstall.js
Arguments:
Directory: /Users/chriz/dev/node_modules/ibm_db
Output:
platform = darwin, arch = x64, node.js version = v19.1.0
make version =GNU Make 3.81

****************************************
You are downloading a package which includes the Node.js module for IBM DB2/Informix.  The module is licensed under the Apache License 2.0. The package also includes IBM ODBC and CLI Driver from IBM, which is automatically downloaded as the node module is installed on your system/device. The license agreement to the IBM ODBC and CLI Driver is available in /Users/chriz/dev/node_modules/ibm_db/installer/clidriver. Check for additional dependencies, which may come with their own license agreement(s). Your use of the components of the package and dependencies constitutes your acceptance of their respective license agreements. If you do not accept the terms of any license agreement(s), then delete the relevant component(s) from your device.
****************************************

Downloading DB2 ODBC CLI Driver from https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/macos64_odbc_cli.tar.gz ...

100.00% | 29943201 bytes downloaded out of 29943201 bytes.

Downloading and extraction of DB2 ODBC CLI Driver completed successfully.

Error: Command failed: node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"
/bin/sh: node-gyp: command not found

    at ChildProcess.exithandler (node:child_process:419:12)
    at ChildProcess.emit (node:events:513:28)
    at maybeClose (node:internal/child_process:1098:16)
    at Socket.<anonymous> (node:internal/child_process:456:11)
    at Socket.emit (node:events:513:28)
    at Pipe.<anonymous> (node:net:298:12) {
  code: 127,
  killed: false,
  signal: null,
  cmd: 'node-gyp configure build  --IS_DOWNLOADED=true --IBM_DB_HOME="$IBM_DB_HOME"'
}
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
bimalkjha commented 1 year ago

@orangecoding Your npm install ibm_db is not showing any error and ibm_db has been installed successfully. The issue is with yarn which is trying to reinstall ibm_db. I would suggest to add node-gyp as dependency in your package.json which get processed by yarn and then install. Also, you can install node-gyp using command npm install -g node-gyp or yarn add node-gyp and then run yarn. It should work. Thanks.

WikiRik commented 11 months ago

Recently we started having the same issue on the v6 branch of sequelize. See https://github.com/sequelize/sequelize/pull/16619 for a failing one without node-gyp as specified dependency, and https://github.com/sequelize/sequelize/pull/16624 to see that it still fails with.

This does not happen on the main branch of sequelize which is using yarn v3 instead of yarn v1. But that should not be the issue

bimalkjha commented 11 months ago

Run below commands and then try:

dirname `which node`
cd to the directory of above output
ls ../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js
ln -s ../lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js node-gyp

Thanks.