My Node.js the way of Learning (I.) _node.js

Source: Internet
Author: User
Tags node server

One, Node.js introduction

These online a lot of information I'm only streamlining

1, what is Node.js
At the core: Node.js is an event-driven server-side JavaScript environment, which means we can use JavaScript to create server-side applications like the Php,ruby and Python languages. It is particularly focused on networking and creating software that interacts with the network.

2, what can you do with node.js?
It can either create a small script that operates on the file system or create a large-scale Web application to run the entire business. Thanks to Node.js's unique design, he is well suited for multiplayer games, real-time systems, networking software and applications with thousands of concurrent users.

3, install and create the first Node.js program,
Installation is very simple, you can Baidu, verify the success of Node.js installation,
can open terminal input node
Output >
Continue typing 1+1
Output 2
The installation was successful. Under the installed directory, create a new Server.js file with the following code:

JS Code

var http = require (' http '); 
Http.createserver (function (req,res) { 
  res.writehead (200,{' content-type ': ' Text/html;charset=utf-8 '}); 
  Res.end (' I'm writing a program \ n ' node.js '); 
} Listen (4000, "127.0.0.1"); 
Console.log (' Server running at Http://127.0.0.1:4000/'); 


Then in the terminal first into the installation directory such as: Just Open is C disk, we installed in D disk
So D:

D:\>CD "program Files <x86>"
D:\Program files <x86>>cd nodejs
D:\Program files <x86> Nodejs>node server.js
Input: server running at http://127.0.0.1:4000
//termination is: Ctrl + C

We can enter url:http://127.0.0.1:4000 in the browser
The page can be displayed: I'm writing a program with Node.js.

Our first node.js was finished.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.