@(web)[node]
在Mac上安装node.js
- 安装Homebrew
- brew install node
Hello World
新建一个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/');
执行:
node server.js
现在可以访问http://127.0.0.1:8124/
node的包管理工具npm
安装node的时候, 会自动安装npm.
搜索第三方库:
npm search [module_name]
网友评论