Home >Web Front-end >JS Tutorial >My Node.js learning path (1)_node.js
1. Introduction to node.js
There is a lot of information online, I only condensed it
1. What is node.js
At its core: Node.js is an event-driven server-side JavaScript environment, which means we can use JavaScript to create server-side applications just like PHP, Ruby and Python. It has a particular focus on the web and creating software that interacts with the web.
2. What can you do with Node.js
It can create small scripts that operate on the file system, or create large-scale web applications to run an entire business. Due to Node.js' unique design, it is ideally 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,
The installation is very simple, you can use Baidu to verify that node.js is installed successfully,
You can open the terminal and enter node
Output>
Continue to enter 1 1
Output 2
Installation successful. Create a new server.js file under the installation directory. The code in it is:
Js code
var http = require('http'); http.createServer(function (req,res){ res.writeHead(200,{'Content-Type':'text/html;charset=utf-8'}); res.end('我在用Node.js写程序 '); }).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: the c drive you just opened, we installed it on the D drive
Then D:
D:\>cd "Program Files <x86>" D:\Program Files <x86>>cd nodejs D:\Program Files <x86> nodejs>node server.js 输入:Server running at http://127.0.0.1:4000 //终止是:Ctrl+C
We can enter the 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 complete.