brianc/node-pg-native

Cant build on ubuntu. Incorrect fixed search path fo node-gyp

Closed this issue · 6 comments

D-Y-V commented

triod@hplub:~$ npm i pg-native -g

libpq@1.8.9 install /home/triod/.npm-global/lib/node_modules/pg-native/node_modules/libpq
node-gyp rebuild

/usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp: 5: /usr/bin/node-gyp: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! libpq@1.8.9 install: node-gyp rebuild
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the libpq@1.8.9 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/triod/.npm/_logs/2020-12-21T11_13_53_338Z-debug.log
triod@hplub:~$ less /home/triod/.npm/_logs/2020-12-21T11_13_53_338Z-debug.log

But node-gyp installed AND exists on PATH.
triod@hplub:$ node-gyp -v
v7.1.2
triod@hplub:
$

Problem:
if packages installed under user account, not root, path to executable should not to be fixed.

For example, how to install as non root regular user:

triod@hplub:/test$ npm config get prefix
/usr/local
triod@hplub:
/test$ mkdir /.npm-global
triod@hplub:
/test$ npm config set prefix '/.npm-global'
triod@hplub:
/test$ export PATH=/.npm-global/bin:$PATH
triod@hplub:
/test$ source /.profile
triod@hplub:
/test$ npm install node-gyp -g

==== > all working nice.
if I do
$ npm i pg-native -g
Yourrs npm installer search by fixed path
/usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin/node-gyp: 5: /usr/bin/node-gyp: not found

Really, this is incorrect.
may be usage which node-gyp can helps.

My env:
triod@hplub:$ npm config get prefix
/home/triod/.npm-global
triod@hplub:
$

Please, fix.

With best wishes - Yuriy.

Please, fix.

With best wishes - Yuriy.

Pull requests are welcome! Happy to review them!

D-Y-V commented

This version of Ubuntu
triod@hplub:~/node-libpq$ cat /etc/issue
Ubuntu 20.04.1 LTS \n \l

.. contains

triod@hplub:/node-libpq$ node -v
v15.4.0
triod@hplub:
/node-libpq$ npm -v
7.0.15
triod@hplub:~/node-libpq$

.......Installed from snap.
(Node && npm ) versions are working. I mean, node-pg-native can be compiled.

Builin node && npm is very old. Unusable(((.

Patch.are() => {
$ sudo -i

apt remove nodejs npm

apt autoremove

snap install npm --classic --channel=15

.. possible step as user (optional, not tested) $ npm update
}

With best wishes - Yuriy.

npm is the one calling node-gyp implicitly because of the presence of a binding.gyp; node-libpq doesn’t hardcode a path to it anywhere. Are you able to install any other packages that build native modules?

D-Y-V commented

Second try. Fresh Ubuntu 20.04.1 LTS with dev tools.
BuiltIn node v10.19.0; npm 6.14.4
$ npm install node-gyp -g
$ npm i pg-native -g

Package compiled && installed.

var Client = require('pg-native')
Thrown:
{ Error: Cannot find module 'pg-native'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18) code: 'MODULE_NOT_FOUND' }

$ npm install libpq -g

Package compiled && installed.

var Libpq = require('libpq');
Thrown:
{ Error: Cannot find module 'libpq'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18) code: 'MODULE_NOT_FOUND' }
var pq = new Libpq();
Thrown:
TypeError: Libpq is not a constructor

D-Y-V commented

No marketing!
But under Centos8 && gentoo all working nice.

D-Y-V commented

Fixed. Move from Ubuntu.