确保安装了python
python -V Python 2.x.x 开始安装:
1.下载nodejs到本地并解压缩
wget http://nodejs.org/dist/v0.9.0/node-v0.9.0.tar.gz
tar zxvf node-v0.9.0.tar.gz
2.进入到该目录编译和安装 cd node-v0.9.0
./configure --prefix=/usr/local/node/0.9.0
这里安装在了/usr/local/node/0.9.0目录下
make
make install
3.配置NODE_HOME
vi /etc/profile 在export PATH USER 。。。一行的上面添加如下内容,并将NODE_HOME/bin设置到系统path中
set for nodejs
export NODE_HOME=/usr/local/node/0.9.0
export PATH=$NODE_HOME/bin:$PATH
保存退出后执行如下命令,使刚才的配置生效
source /etc/profile
执行node -h命令验证设置成功
node -h Usage: node [options] [ -e script | script.js ] [arguments]
node debug script.js [arguments]
Options:
-v, --version print node's version
-e, --eval script evaluate script
-p, --print print result of --eval
-i, --interactive always enter the REPL even if stdin
does not appear to be a terminal
--no-deprecation silence deprecation warnings
--trace-deprecation show stack traces on deprecations
--v8-options print v8 command line options
--max-stack-size=val set max v8 stack size (bytes)
Environment variables:
NODE_PATH ':'-separated list of directories
prefixed to the module search path.
NODE_MODULE_CONTEXTS Set to 1 to load modules in their own
global contexts.
NODE_DISABLE_COLORS Set to 1 to disable colors in the REPL
Documentation can be found at http://nodejs.org/