NodeJS npm install pg failed
Asked Answered
S

3

8

Im trying to npm install pg on my ubuntu virtual machine and i got error:

> [email protected] install /usr/local/lib/node_modules/core/node_modules/pg
> node-gyp rebuild || (exit 0)

gyp: binding.gyp not found (cwd: /usr/local/lib/node_modules/core/node_modules/pg) while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.11.0-12-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/core/node_modules/pg
gyp ERR! node -v v0.10.15
gyp ERR! node-gyp -v v0.10.9
gyp ERR! not ok 
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /root/npm-debug.log
npm ERR! not ok code 0


nodejs -v
v0.10.15
npm -v
1.2.18

Any idea how to fix it?

Stunning answered 14/11, 2013 at 7:59 Comment(4)
Your binding.gyp is missing somehow. Did you try to reinstall it ?Bosporus
Could you show us your $PATH? Also, please see this relevant question.Phosphide
echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSkyline
sudo apt-get install libpq-dev helped :) Thanks!Skyline
S
13

I have installed libpq-dev library

sudo apt-get install libpq-dev

it helped ;)

Stunning answered 14/11, 2013 at 9:48 Comment(2)
This works. OP, please accept this as the answer for others benefit.Empressement
Please put some explanation in this answer.Shelf
M
11

Try to install node-gyp first into the global scope?

sudo npm -g install node-gyp

You should get a result (after all the tgz's are pulled in) that looks like this

/usr/local/bin/node-gyp -> /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js
[email protected] /usr/local/lib/node_modules/node-gyp
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
Malena answered 12/12, 2013 at 1:3 Comment(0)
D
3

Try running the following commands and then run npm install, this will take the node's default node-gyp module. (No need to have multiple as node package already provides that)

Updating the node & NPM

sudo npm cache clean -f
sudo npm install -g n
sudo n 4.4.5
sudo npm install npm -g

Removing additional Node-gyp module

sudo npm uninstall node-gyp -g
sudo npm uninstall node-gyp
Dessiedessma answered 30/5, 2016 at 12:31 Comment(1)
Is the package n an alias for node?Surgeonfish

© 2022 - 2024 — McMap. All rights reserved.