美文网首页
在Mac上安装node.js

在Mac上安装node.js

作者: 不是谢志伟 | 来源:发表于2015-09-08 10:10 被阅读7485次

@(web)[node]

在Mac上安装node.js

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]

相关文章

网友评论

      本文标题:在Mac上安装node.js

      本文链接:https://www.haomeiwen.com/subject/dizucttx.html