node.js 笔记

教程总结笔记:

学习网站:http://www.runoob.com/nodejs/nodejs-install-setup.html

Node.js 中文网及安装文件下载:

http://nodejs.cn/download/

安装完成后,cmd --->  path

看到此后,安装成功

 

查看node版本

node -v 

查看npm版本

 顺便安装下淘宝镜像:

npm install -g cnpm --registry=http://registry.npm.taobao.org

 浏览器打开node的第一个Hello Word

任意目录下建:node.test.js

var http = require('http');

http.createServer(function (request, response) {

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

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

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

该目录cmd 打node node.test

//cmd 里:
$ node test02.http.js
Server running at http://127.0.0.1:8888/

浏览器:http://127.0.0.1:8888/

.

原文地址:https://www.cnblogs.com/xiangsj/p/6892528.html