如何设置Node.js的节点路径(Ubuntu) [英] How to set node path for nodejs (Ubuntu)

查看:351
本文介绍了如何设置Node.js的节点路径(Ubuntu)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置nodejs来访问postgres数据库。到目前为止,我已经完成了以下操作(https://gist.github.com/579814):

I'm trying to setup nodejs to access a postgres database. What I've done so far is the following (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驱动程序

so far, so good. However, when I try to install the postgres driver

npm install pg

我得到以下信息:


node-waf configure build || true

node-waf configure build || true



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}

我一直在寻找设置节点路径的方法,尽管没有找到到目前为止没有任何帮助-可能还因为我对Node.js完全陌生,所以我会对任何提示感到高兴。

I've been looking around for setting the node path, although haven't found anything of help so far - probably also because I'm totally new to nodejs, so I'd be happy about any hint.

推荐答案

现在,您已经在Ubuntu中安装了NodeJS。您应该设置 / etc / environment 并加载可以由其他用户执行的nodeJS路径。例如:

Now, you have NodeJS installed in your Ubuntu. You should set /etc/environment and load nodeJS path that can be executed by another users. For example:

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"

这篇关于如何设置Node.js的节点路径(Ubuntu)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆