Node.js学习笔记之一:入门

关于Node.js这里不再赘述,直接开始学习

第一步下载安装node.js  此处安装window版本

可以在命令行里查看版本

>node -v


编写第一个hello world


编写js文件helloworld.js,代码如下:

var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World,This is my first node js study!\n');}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

使用node运行:



在浏览器访问:





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章