linux上部署nodejs
环境:
# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-ia32:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.9 (Final)
Release: 5.9
Codename: Final
nodejs版本-v0.8.7;
1.先下载nodejs:
# wget http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz
2.解压文件
# tar xvf node-v0.8.7.tar.gz
3.进入解压目录
# cd node-v0.8.7
4.安装node.js
# ./configure
# make
# make install
在 ./configure 时出现错误提示:
File "./configure", line 331
o['default_configuration'] = 'Debug' if options.debug else 'Release'
网上查找资料说是python版本过低导致;查看了一下版本是2.4.3,果断升级至2.7.3后,再操作第4步;最后搞定;
5.校验是否成功安装,输入命令:
# node -v
v0.8.7
注:显示如上内容即表示已经安装成功;
6.还可以创建一个test.js文件进行测试,文件内容为:console.log('Hello World.');
# node test.js
Hello World.
注:如显示如上内容也即表示nodejs工作正常;
7. nodijs 插件安装
# cd /usr/local/lib/
npm install express 4.0.0
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
npm install [email protected]
注:如果安装异常,可以更改下载地址或者设置代理即可!
比如: npm --registry "http://npm.hacknodejs.com/" install [email protected]
npm config set proxy http://59.172.208.190:8080
npm config set https-proxy http://59.172.208.190:8080
npm config set registry http://registry.npmjs.org
npm 如何使用可参考:http://hi.baidu.com/alimyself/item/3ba5200faba0c7c92f4c6b43