Node.js (install start test)

  • 2020-03-30 03:14:47
  • OfStack

concept

Node.js is a platform built on top of Chrome javascript runtime that makes it easy to build fast, scalable web applications. Node.js USES event-driven, non-blocking I/O mode, which makes it lightweight, efficient, and perfect for data-intensive real-time applications running between distributed devices.

The installation

Here we mainly introduce the most simple and convenient installation method based on Windows platform. We first directly visit the official website of node. js (link: http://www.nodejs.org/), and directly click the Install button to download and Install.

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414922.png ">

Click the Run button to start running

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414923.png ">

Continue by clicking the Next button

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414924.png ">

Check Accept and then click the Next button directly

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414925.png ">

Select the installation directory and click Next

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414926.png ">

Select the feature you want to install, we'll leave it as the default, and click the Next button

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414927.png ">

Click Install to complete the installation

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414928.png ">

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414929.png ">

Click the Finish button to Finish the installation

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414930.png ">

Start Node. Js

Two ways:

1. From the start menu, click the application icon to launch

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414931.png ">

2. Enter node directly into the node environment from the command line, and type console.log("hello world!"). ) test console Node console output

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414932.png ">

Test the Node

Create a testnode.js file on the machine on which you are running node.js, and enter the following test code

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414933.png ">

Then store testnode.js to a disk directory, open the node.js command line, switch to the node.js test code directory, in the command line input node testnode.js command, firewall warning window (due to firewall Settings), do not panic, directly click Allow Access button to Allow the run.

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414934.png ">

 

Note: for the first time, the author inputted testnode.js in a muddleheaded way, and the result was an operation exception, which was very embarrassing, mainly because the author was not familiar with node.js. This exception can be avoided by simply entering the node run command correctly.

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414935.png ">

 

Then open a browser and type in the browser address :http://127.0.0.1:3000 or (link: http://localhost:3000/) to run the testnode.js file.

The operation effect is as follows:

< img Alt = "" border = 0 SRC =" / / files.jb51.net/file_images/article/201406/2014060915414936.png ">

Well, everything seems to be working fine. That's all for today's initial exploration of node. js.


Related articles: