1. Introduction to node.js
I've just simplified this information on the Internet
1. What is node.js
From the core point of view: Node.js is an event-driven server-side javascript environment. That is to say, we can use javascript to create server-side applications like using PHP, Ruby and Python languages. It is particularly focused on networking and creating software that interacts with networks.
2. What can I do with Node.js
It can either create small scripts that operate on the file system or create large-scale web applications to run the entire business. Thanks to the unique design of Node.js, it is ideal 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 very simple. You can verify that the node.js installation is successful.
You can open the terminal and enter node
Output>
Continue to enter 1+1
Output 2
Installation was successful. Create a new server.js file in the installation directory as follows:
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 program with Node.js/n'); }).listen(4000,"127.0.0.1"); console.log('Server running at http://127.0.0.1:4000/');Then enter the installation directory in the terminal first, for example: Just opened it is disk c, we installed it on disk D
Then D:
D:/Program Files <x86>"D:/Program Files <x86>>cd nodejsD:/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 in the browser: http://127.0.0.1:4000
The web page can display: I am writing a program using Node.js
Our first node.js is done.