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.