Under Windows 7 Node.js Web development environment built notebook

What Node.js that?

We look at how to say in Wikipedia? JavaScript is a script running in the browser, it is simple, lightweight, easy to edit, this script is commonly used browser front-end programming, but one day a developer Ryan found that the Front scripting language can run time on the server, a storm sweeping through the world began. Node.js is a platform built on Chrome JavaScript runtime for easily building fast response, easy to expand network applications. Node.js event-driven, non-blocking I / O model and to be lightweight and efficient, ideal for data-intensive real-time applications running on distributed devices.
  Node is a Javascript runtime environment (runtime). In fact, it is Google V8 engine package. Javascript execution speed of the V8 engine is very fast, very good performance. Node for some special use case has been optimized to provide alternative API, making V8 run better in a non-browser environment.

Do you understand?

Honestly, I did not understand!

So Node.js what in the end is it?

Web back-end development language, you understand this?

asp, jsp, php is do you know anything?

Well, you want to use JS to access the database to handle user requests?

===============================================


Node.js is an open source project, its founder Ryan Dahl. Later this open source project is very popular, Joyent this company noticed Node.js, decided to sponsor the project. Ryan Dahl joined the company in 2010, responsible for the development of full-time Node.js project.

About Node.js, and later because of management problems Joyent, several important developers away, a separate hill, began an open-source project called io.js, the community was very active. However, September 15, 2015, io.js fit again and Node.js, Node.js v4.0.0 released.

Download Node.js

Official website address: https: //nodejs.org/en/

You can click on the link to enter the following figure:

I have a Windows 7 x64 system, select the version: v4.2.4 LTS, relatively more mature and reliable version;

Install Node.js

Step by step installation on the line, there's really nothing, but to no contact with the texture of a visual impression!

 

After installation is complete, the Start menu adds a directory of Node.js, as shown below:

Click on Node.js, open a command line window, type "os" Enter try

The first Web server

Contact more and found a lot of Web development language is when you can write your own Web server based on the language itself!
Go language so, Python language so, Node.js is also true;

But usually we may not do so at the time of project development, because usually already has an excellent server framework can be used.

Save the following code as "helloworld.js" file:

var http = require('http');

var server = http.createServer(function(request, response) {
response.end("hello world!");
});

server.listen(8080);

 

A Web server so few lines of code?
Yes, yes !! But this is a more mentally Web server, it will only return "hello world!".

require front-end for many small partners should be familiar, right?

As long as you js on the line, you can become a master of the back-end Web + front-end development!

打开命令行,切换到“helloworld.js”文件的保存目录,执行:node helloworld.js

如果你开启了防火墙,应该会看到下图:

点击允许访问,打开浏览器,输入“http://localhost:8080/”访问看看吧!

注意:如果是一直处于cmd模式会占用端口号,可以直接CTR+C退出node

小结

到这里Node.js Web的开发环境就搭建完了,就这么简单,你也试试吧!

===============================================================

 

借鉴:https://blog.csdn.net/testcs_dn/article/details/50532775

Guess you like

Origin www.cnblogs.com/hxun/p/10939387.html