0

I'm very (very) new to node.js, and also fairly green when it comes to server side configuration and coding. (I have a long history of client-side programming, most recently with Adobe Flex and ActionScript.)

Anyhow, I asked Rackspace (who manages a Linux server for me) to install node.js and node-postgres.

From the comments in the ticket, that installation went like this:


node.js

Running Transaction
  Installing     : nodejs-stable-release                             [1/1] 

Installed: nodejs-stable-release.noarch 0:5-3
Complete!

and node-postgres

[root@237175-web2 src]# 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.6.17.tgz  
npm http GET https://registry.npmjs.org/generic-pool/1.0.9  
npm http 200 https://registry.npmjs.org/generic-pool/1.0.9  
npm http GET https://registry.npmjs.org/generic-pool/-/generic-pool-1.0.9.tgz  

 [email protected] install /usr/src/node_modules/pg  
 node-waf configure build || (exit 0)

Checking for program g++ or c++          : /usr/bin/g++   
Checking for program cpp                 : /usr/bin/cpp   
Checking for program ar                  : /usr/bin/ar   
Checking for program ranlib              : /usr/bin/ranlib   
Checking for g++                         : ok    
Checking for node path                   : not found   
Checking for node prefix                 : ok /usr   
Checking for program pg_config           : /usr/bin/pg_config   
'configure' finished successfully (0.051s)  
Waf: Entering directory `/usr/src/node_modules/pg/build'  
[1/2] cxx: src/binding.cc -> build/Release/src/binding_1.o  
[2/2] cxx_link: build/Release/src/binding_1.o -> build/Release/binding.node  
Waf: Leaving directory `/usr/src/node_modules/pg/build'  
'build' finished successfully (0.745s)  
[email protected] ./node_modules/pg  
+-- [email protected]  

More info:

[root@237175-web2 ~]# ls -la /usr/src/node_modules/pg  
total 68  
drwxr-xr-x 9 root root 4096 Apr 26 22:34 .  
drwxr-xr-x 3 root root 4096 Apr 26 22:34 ..  
drwxr-xr-x 2 root root 4096 Apr 26 22:34 benchmark  
drwxr-xr-x 4 root root 4096 Apr 26 22:34 build  
drwxr-xr-x 3 root root 4096 Apr 26 22:34 lib  
-rw-r--r-- 1 root root 5618 Apr 26 22:34 .lock-wscript  
-rw-r--r-- 1 root root 1269 Feb 23 23:58 Makefile  
drwxr-xr-x 3 root root 4096 Apr 26 22:34 node_modules  
-rw-r--r-- 1 root root   21 Mar  3 15:19 .npmignore  
-rw-r--r-- 1 root root  962 Apr 26 22:34 package.json  
-rw-r--r-- 1 root root 6843 Mar 27 09:30 README.md  
drwxr-xr-x 2 root root 4096 Apr 26 22:34 script  
drwxr-xr-x 2 root root 4096 Mar 21 23:37 src  
drwxr-xr-x 5 root root 4096 Apr 26 22:34 test  
-rw-r--r-- 1 root root  990 Feb 23 23:58 wscript  
[root@237175-web2 ~]#  

A little “Hello world” node.js example works fine (hooray!), but a simple Postgres example fails on the require('pg') statement, saying that the module cannot be found. I've looked on the server and can't find a pg.js file anywhere.

Any clue as to why the node-postgres build failed?

7
  • Please provide some details on what path you're working in vs. which path you're installing the pg npm into. And also, which path is your app.js in? Commented Apr 28, 2012 at 18:32
  • @k00k, it looks like the pg npm was installed to /usr/src/node_modules/pg, but I can't find any pg.js ANYWHERE on the server. The file with my application is /home/barton/nodetest Commented Apr 28, 2012 at 18:54
  • what do you see when you type ls -la /usr/src/node_modules/pg Commented Apr 28, 2012 at 18:55
  • @k00k, just edited my post to give you that info. Commented Apr 28, 2012 at 19:33
  • Right, so it's there. Try changing your require to var pg = require('/usr/src/node_modules/pg'); Commented Apr 28, 2012 at 20:48

1 Answer 1

1

Install it globally:

npm install -g pg

You may need to become root, e.g. with

sudo npm install -g pg
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.