Node.js初探之hello world

昨天公司内部培训,主讲人王老板对Node.js评价很高,连用几个“变态”来形容,恰好今天周末,有时间来认识下Node.js,对一门新语言最好的认识,是让其输出“hello world”,今天我就利用Node.js输入“hello world”。
一、安装Node.js
(1)下载Node.js
去Node.js官网下载,因为我的电脑是windows 64位win7系统,所以下载是64位安装包。

(2)安装Node.js
双击下载下来的安装包,选择安装路径,傻瓜似的点击下一步就行了。
(3)将Node.exe加入环境变量中

二、输出“hello world”
(1)第一个例子
建立helloworldDemo.js文件,然后在里面输入:
console.log("hello world");

(2)第二例子
建立helloworldDemo2.js文件,然后在里面输入:
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.writeHead(, {"Content-Type": "text/html"});
response.write("Hello World!");
response.end();
}).listen();
sys.puts("Server running at http://localhost:8080/");
然后我们在命名台中输入命令node helloworldDemo2.js,在浏览器输入http://localhost:8080/


三、进一步学习
至此,简单“hello world”学习已结束,欲进一步学习Node.js,可以查看官网相关文档以及相关书集。
这里有一本入门级书籍:《Node入门》。
Node.js初探之hello world的更多相关文章
- Node.js初探之GET方式传输
Node.js初探之GET方式传输 例子:form用GET方法向后台传东西 html文件: <form action="http://localhost:8080/aaa" ...
- Node.js 初探
概念 Node.js 是构建在Chrome javascript runtime之上的平台,能够很容易的构建快速的,可伸缩性的网络应用程序.Node.js使用事件驱动,非阻塞I/O 模式,这使它能够更 ...
- Node.js系列之node.js初探
官方介绍:Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable n ...
- Node.js初探之POST方式传输
小知识:POST比GET传输的数据量大很多 POST发数据--"分段" 实例: 准备一个form.html文件: <!DOCTYPE html> <html> ...
- Node.js初探之实现能向前台返回东西的简单服务器
nodejs nodejs文件就是一个简单的js文件. 在shell中运行 Step 1. 打开终端,进入这个js文件所在目#录 Step 2. 用 'node 文件名.js' 命令运行它即可. 用n ...
- Node.js初探
1, 设计高性能.Web服务器的几个要点:事件驱动.非阻塞I/O 2,常见Web服务器架构: Web服务器的功能: 接受HTTP请求(GET.POST.DELETE.PUT.PATCH) 处理HTTP ...
- Node.js 爬虫初探
前言 在学习慕课网视频和Cnode新手入门接触到爬虫,说是爬虫初探,其实并没有用到爬虫相关第三方类库,主要用了node.js基础模块http.网页分析工具cherrio. 使用http直接获取url路 ...
- [转] Node.js 服务端实践之 GraphQL 初探
https://medium.com/the-graphqlhub/your-first-graphql-server-3c766ab4f0a2#.n88wyan4e 0.问题来了 DT 时代,各种业 ...
- 初探node.js
一.定义及优势 定义:Node.js是一个基于 Chrome V8 引擎 的 JavaScript 运行时,它以事件驱动为基础实现了非阻塞模型. 优势:由于Web场景下的大多数任务(静态资源读取.数据 ...
随机推荐
- C++中不同数据类型的互相转换
1.string --> char * char * p = (char*)str.c_str(); 2.char * -->string char *p = "aaa& ...
- Read/Write file in Android
http://www.cnblogs.com/freeliver54/archive/2011/09/16/2178910.html
- Python使用CGIHTTPServer调用shell作为cgi脚本
#!/bin/bash echo "Content-Type:text/html" echo "" echo "hello world!" ...
- JMeter学习(十)内存溢出解决方法
使用jmeter进行压力测试时遇到一段时间后报内存溢出outfmenmory错误,导致jmeter卡死了,先尝试在jmeter.bat中增加了JVM_ARGS="-Xmx2048m -Xms ...
- IOS 取消表格单元格 TableViewCell 去掉高亮状态 点击Cell取消选择状态
以下是两种实现效果 1. 自定义cell 继承UITableViewCell 重写 -(void)setSelected:(BOOL)selected animated:(BOOL)animated ...
- 基于GRPC+consul通信的服务化框架(转)
原文:http://blog.csdn.net/yeyincai/article/details/51470475 -.背景 谈论服务化框架的时候,我们首先先了解这些概念:SOA.ESB.OSGi.s ...
- input屏蔽历史记录
设置input 的扩展属性 autocomplete为off即可 <input type="text" autocomplete="off" />
- Erlang 103 Erlang分布式编程
Outline 笔记系列 Erlang环境和顺序编程Erlang并发编程Erlang分布式编程YawsErlang/OTP 日期 变更说明 2014-11-23 A Outl ...
- document的一点点
var str = "hello world" document.write(str.length)输出字符串长度 12 给string 添加样式 <p>Big: ...
- Codeforces Round #378 (Div. 2) A B C D 施工中
A. Grasshopper And the String time limit per test 1 second memory limit per test 256 megabytes input ...