node.js学习之路
打开cmd命令窗口,输入node,回车;
cmd窗口会出现”>”输入".help”,回车;
> .help
.break Sometimes you get stuck, this gets you out
.clear Break, and also clear the local context
.exit Exit the repl
.help Show repl options
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
恭喜您基本安装成功!
在D盘建立一个文件夹:Nodejs
在些文件夹下新建一个文本文件,并输入
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
保存,并重命名文件为"HelloWorld.js”;
然后在cmd下到D盘下的Nodejs文件下输入:node HelloWorld.js
在本地浏览器地址中,输入:http://127.0.0.1:8124/,OK,欢迎进入Node.js世界;
提示:在命令窗口下,按Ctrl+Pause(Break)可结束刚启动HelloWorld--Web服务;