Mac上安装node.js

时间:2021-07-04 04:39:56

1、下载node for mac并一路默认安装

Mac上安装node.js

2、测试成功否

Mac上安装node.js

3、copy this file to test(save as javascript file)

var http = require('http');

http.createServer(function(request,response){
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('hello world\n');
}).listen(8888); console.log('Server running at http://127.0.0.1:8888/');

cd到正确路径下

Mac上安装node.js

打开浏览器,出现输入地址和端口号

Mac上安装node.js

yeah you succeed!