concept
Node.js is a platform built on Chrome javascript runtime, which can easily build fast, scalable web applications. Node.js uses event-driven, non-blocking I/O mode, which makes it lighter, efficient and perfect for data-intensive real-time applications running between distributed devices.
Install
Here we mainly introduce the simplest and most convenient installation method based on the Windows platform. First, we directly visit the node.js official website http://www.nodejs.org/ and directly click the Install button to start downloading and installing.
Click the Run button to start running
Continue to click the Next button
Check Accept and click the Next button directly
Select the installation directory and click Next
Select the function you need to install. Here we keep the default installation status and click the Next button
Click Install to wait for the installation to be completed
Click the Finish button to end the installation
Start Node.js
Two ways:
1. Click the application icon from the Start menu to start
2. Enter node through the command line and enter console.log("hello world!") to test console Node console output
Test Node
Create a testnode.js file on the machine running Node.js and enter the following test code
Then store testnode.js to a disk directory, open the node.js command line, switch to the node.js test code directory, enter the node testnode.js command in the command line, and a firewall warning window appears (caused by firewall settings). Don't panic, just click the Allow Access button to allow running.
Note: The first time I was confused and directly entered testnode.js, but the result was an abnormal operation, which was very embarrassing. It was mainly due to the author's unfamiliarity with node.js, and the exception is shown in the figure below. Just enter the node run command correctly to avoid the exception.
Then open the browser and enter the browsing address: http://127.0.0.1:3000 or http://localhost:3000 to run the testnode.js file.
The operation effect is as follows:
OK, it seems that everything is running normally. This is the end of my initial exploration of Node.js today. I will further record my learning process in future articles. Thank you.