我正在尝试设置nodejs来访问postgres数据库。到目前为止我所做的是以下内容(https://gist.github.com/579814):
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
然后
git clone git://github.com/isaacs/npm.git
make
make install
到目前为止,这么好。但是,当我尝试安装postgres驱动程序时
npm install pg
我得到以下内容:
node-waf configure build ||真
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/local
Checking for program pg_config : /usr/bin/pg_config
'configure' finished successfully (0.066s)
Waf: Entering directory `/home/christian/node_modules/pg/build'
[1/2] cxx: src/binding.cc -> build/default/src/binding_1.o
../src/binding.cc:3:25: fatal error: node_events.h: No such file or directory
compilation terminated.
Waf: Leaving directory `/home/christian/node_modules/pg/build'
Build failed: -> task failed (err #1):
{task: cxx binding.cc -> binding_1.o}
我一直在寻找设置节点路径,虽然到目前为止还没有找到任何帮助 - 可能也因为我对nodejs全新,所以我会对任何提示感到高兴。
答案 0 :(得分:14)
现在,您已在Ubuntu中安装了NodeJS。您应该设置/etc/environment
并加载可由其他用户执行的nodeJS路径。例如:
NODE="/home/ubuntu/local/node"
NODE_PATH="/usr/local/lib/node_modules"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$NODE/bin:$NODE/lib/node_modules"
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
答案 1 :(得分:7)
在bash中执行此操作:
echo 'export NODE_PATH=~/local/:~/local/node_modules' >> ~/.bashrc
答案 2 :(得分:0)
Auteur: Ryan Dahl <ry@tinyclouds.org> 2011-07-19 10:46:38
Auteur du commit: Ryan Dahl <ry@tinyclouds.org> 2011-07-19 10:46:38
Parent: 0a3fc1d9c8becc32c63ae736ca2b3719a3d03c5b (Remove StatWatcher's dep on C++ EventEmitter)
Enfant: 061ce7b0ac370c8a5ae93d95ab7da171cbd488f0 (net_uv: Fix simple/test-http-expect-continue.js)
Branche: master, remotes/origin/master
Suit: v0.5.1
Précède: v0.5.2
Finally remove node::EventEmitter
答案 3 :(得分:0)
我遇到了同样的问题。 问题是我在package.js中指定了旧版本的PG 删除旧版本后,我可以毫无问题地安装PG。