I am having trouble installing the Postgres database module for Node.js, every time I run the command "npm install pg" I get the following error:
C:>npm install pg
npm http GET https://registry.npmjs.org/pg
npm http 200 https://registry.npmjs.org/pg
npm http GET https://registry.npmjs.org/pg/-/pg-0.12.1.tgz
npm http 200 https://registry.npmjs.org/pg/-/pg-0.12.1.tgz
npm http GET https://registry.npmjs.org/generic-pool/2.0.2
npm http 200 https://registry.npmjs.org/generic-pool/2.0.2
npm http GET https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz
npm http 200 https://registry.npmjs.org/generic-pool/-/generic-pool-2.0.2.tgz

[email protected] install C:\node_modules\pg
node-gyp rebuild || (exit 0)

C:\node_modules\pg>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-b
in\....\node_modules\node-gyp\bin\node-gyp.js" rebuild
'pg_config' is not recognized as an internal or external command,
operable program or batch file.
gyp: Call to 'pg_config --libdir' returned exit status 1. while trying to load b
inding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (C:\Program Files\nodejs\node_module
s\npm\node_modules\node-gyp\lib\configure.js:420:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Windows_NT 5.1.2600
gyp ERR! command "node" "C:\Program Files\nodejs\node_modules\npm\node_modu
les\node-gyp\bin\node-gyp.js" "rebuild"
gyp ERR! cwd C:\node_modules\pg
gyp ERR! node -v v0.8.17
gyp ERR! node-gyp -v v0.8.2
gyp ERR! not ok
[email protected] node_modules\pg
└── [email protected]

This error occurs on both my work machine (linux/windows box) and my personal machine (windows) at home. Any ideas?

Also I should mention I already have Python 2.7.3 installed.

Also I have two more questions related to Node.js:

1) I've heard that there are two different ways to connect to the database using Node.js, one way is via javascript using the pg module and the other is via a native extension (can't remember the name). What do you guys recommend me to use and which is easier/better for a novice in Node.js to pick up?

2) I've read people write about developing in either Node.js only, or via Node.js/Express combo or Node.js/Knockout library. Is one better than the other? This is in terms of the web application able to access a remote database (as per our project).

I am new to Node.js so hence the basic questions! I am not just doing this for work but for personal projects (I have preference for node.js over RoR) as well so all help appreciated! Thanks!

share|improve this question
Do you have the PostgreSQL libraries and headers installed? Your problem with pg_config --libdir suggest that you don't or you have a PATH problem (i.e. pg_config is not in your PATH). – mu is too short yesterday
feedback

1 Answer

You're on Windows:

'pg_config' is not recognized as an internal or external command, operable program or batch file.

so I suggest you get a pre-built binary of the pg module. Compiling things on windows is ... fun.

The immediate error is that the pg_config executable is not on the PATH, but there'll be lots more after you fix that. Get a prebuilt executable unless you plan on a journey of discovery and swearing.

share|improve this answer
well you happen to know where I could get a pre-built pg binary? Otherwise I'll have to work with linux entirely. I did actually add pg_config to my windows environment path and it was complaining about make not being installed due to there being no vc++ 2008 etc... – JackSparrow123 7 hours ago
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.