NODE.JS
访问http://nodejs.org/ 最新版Node.js pkg包
直接默认安装 会提示
Node was installed at “/usr/local/bin/node”
npm was installed at “/usr/local/bin/npm”
Make sure that /usr/local/bin is in your $PATH.
在 /usr/local/bin/node 路径下创建example.js 如无法创建 请参照上方设置权限
代码:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
保存 并在终端输入 node example.js 正常则显示 Server running at http://127.0.0.1:1337/
打开浏览器 输入地址http://127.0.0.1:1337/ 进行查看。