1.下载node.js安装包
http://nodejs.org/dist/v0.6.3/node-v0.6.3.tar.gz
2.安装node.js
[quote]tar xzvf node-v0.6.3.tar.gz
cd node-v0.6.3
./configure
make
make install
[/quote]
3.切换到root
[quote]su -
输入密码[/quote]
4.安装npm
[quote]curl http://npmjs.org/install.sh | sh
[/quote]
5.设置国内镜像
[quote]npm config set registry http://registry.npmjs.vitecho.com[/quote]
6.安装第三方模块
[quote]npm install express ejs mysql[/quote]
hello word例子1:
新建一个文件hello.js
执行node helloworld.js
hello word例子2:
新建一个文件server.js
执行node server.js
浏览器访问:http://localhost:8888/
http://nodejs.org/dist/v0.6.3/node-v0.6.3.tar.gz
2.安装node.js
[quote]tar xzvf node-v0.6.3.tar.gz
cd node-v0.6.3
./configure
make
make install
[/quote]
3.切换到root
[quote]su -
输入密码[/quote]
4.安装npm
[quote]curl http://npmjs.org/install.sh | sh
[/quote]
5.设置国内镜像
[quote]npm config set registry http://registry.npmjs.vitecho.com[/quote]
6.安装第三方模块
[quote]npm install express ejs mysql[/quote]
hello word例子1:
新建一个文件hello.js
console.log("Hello World");
执行node helloworld.js
hello word例子2:
新建一个文件server.js
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
执行node server.js
浏览器访问:http://localhost:8888/