@(web)[node]
在Mac上安裝node.js
- 安裝Homebrew
- brew install node
Hello World
新建一個(gè)server.js文件:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');
執(zhí)行:
node server.js
現(xiàn)在可以訪問http://127.0.0.1:8124/
node的包管理工具npm
安裝node的時(shí)候, 會自動(dòng)安裝npm.
搜索第三方庫:
npm search [module_name]