My path to Node. js Learning (1) _ node. js

Source: Internet
Author: User
Tags node server
This is a special Node. js learning note for beginners. This note will show you how to Start Node. js step by step. 1. Introduction to node. js

I have a lot of information on the Internet.

1. What is node. js?
At the core, Node. js is an event-driven server-side javascript environment. That is to say, we can use javascript to create server-side applications like PHP, Ruby, and Python. It is especially focused on networks and software that creates interactions with networks.

2. What can I do with Node. js?
It can create a small script to operate the file system, or create a large-scale Web application to run the entire business. Due to the unique design of Node. js, It is very suitable for multiplayer games, real-time systems, networked software and applications with thousands of concurrent users.

3. Install and create the first node. js program,
The installation is simple. You can use Baidu to verify that node. js is successfully installed,
You can open the terminal and enter node
Output>
Continue input 1 + 1
Output 2
The installation is successful. The code in the new server. js file under the installation directory is:

Js Code

Var http = require ('http'); http. createServer (function (req, res) {res. writeHead (200, {'content-type': 'text/html; charset = UTF-8 '}); res. end ('I am using Node. js write program ');}). listen (4000, "127.0.0.1"); console. log ('server running at http: // 127.0.0.1: 4000 /');


Then go to the installation directory on the terminal. For example, if the drive C is just opened, we will install it on disk D.
Then D:

D: \> cd "Program Files
 
  
"D: \ Program Files
  
   
> Cd nodejsD: \ Program Files
   
    
Nodejs> node server. js input: Server running at http: // 127.0.0.1: 4000 // termination: Ctrl + C
   
  
 

You can enter url: http: // 127.0.0.1: 4000 in the browser.
The web page shows that I am using Node. js to write programs.

Our first node. js is complete.

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.