nodejs安装配置

1.安装node.js(6.3.0)
2.检测PATH环境变量是否配置了Node.js
cmd下
node --version
3.D:/www/nodejs文件夹下创建hello.js
var http = require('http');

http.createServer(function (request, response) {

// 发送 HTTP 头部
// HTTP 状态值: 200 : OK
// 内容类型: text/plain
response.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});

// 发送响应数据 "Hello World"
response.end('Hello World\n');
}).listen(8888);

// 终端打印如下信息
console.log('Server running at http://127.0.0.1:8888/');

4.启动服务
cmd下执行:
node hello.js

浏览器访问:http://localhost:8888
hello,world

5.环境配置

参考https://www.jianshu.com/p/03a76b2e7e00

posted @ 2017-08-27 11:04  开始战斗  阅读(246)  评论(0编辑  收藏  举报