我对node.js非常(非常)新手,在服务器端配置和编码方面也非常环保。 (我有很长的客户端编程历史,最近有Adobe Flex和ActionScript。)
无论如何,我问Rackspace(谁为我管理Linux服务器)安装node.js和node-postgres。
根据故障单中的评论,该安装是这样的:
的node.js
Running Transaction
Installing : nodejs-stable-release [1/1]
Installed: nodejs-stable-release.noarch 0:5-3
Complete!
和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
pg@0.6.17 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)
pg@0.6.17 ./node_modules/pg
+-- generic-pool@1.0.9
更多信息:
[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 ~]#
一个小的“Hello world”node.js示例工作正常(万岁!),但是一个简单的Postgres示例在require('pg')
语句上失败,说无法找到该模块。我查看了服务器,无法在任何地方找到pg.js
文件。
有关为什么node-postgres构建失败的任何线索?
答案 0 :(得分:1)
全局安装:
npm install -g pg
您可能需要成为root用户,例如与
sudo npm install -g pg