My node. js learning path (1)

  • 2020-03-30 03:30:15
  • OfStack

Introduction to node.js
 
There is a lot of information on the Internet
 

1. What is node.js
At its core, node. js is an event-driven, server-side javascript environment, which means that you can create server-side applications using javascript just as you would with PHP, Ruby, and Python. It is particularly focused on the web and creating software that interacts with it.

2. What can you do with node. js
It can create either a small script that operates on a file system or a large Web application that runs an entire business. Thanks to its unique design, node. js is ideal 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 that node. js installation is successful,
The terminal input node can be opened
The output >
So I'm going to continue with 1 plus 1
The output of 2
Successful installation. In the directory under the installation of a new server.js file 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 am using Node.js Write programs n'); 
}).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 opened is the c disk, we installed in the D disk
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
//The termination is: Ctrl+C

We can enter the url: (link: http://127.0.0.1:4000) in the browser.
The web page says, "I'm writing node. js.
 
Our first node.js is done.


Related articles: