It is very convenient to install Node. js on Windows. You only need to visit the official node. js website http://www.nodejs.org/and click the downloadlink. Then choose windowsinstaller (32bit, 64bit optional ),
It is very convenient to install Node. js on Windows. You only need to visit the official node. js website http://www.nodejs.org/, click the downloadchain, and then select Windows Installer (32bit, 64bit optional) to download the installation package. After the download is complete, double-click the installation.
Installation steps:
Click "Next"
Accept the agreement and click "Next"
Select the installation directory and click "Next"
Select the component to be installed. By default, npm Package Manager is installed and environment variables are automatically added. Then, click "Next"
Click "Install" to start the installation. The installation progress bar appears. Click "Finish" to complete the installation.
Start node
We can start node in two ways:
Fang 1: double-click the node. js shortcut
Party 2: Open the windows command line. Because the environment variables have been automatically configured during installation, we can directly enter node to enter the node. js interaction mode.
Output "Hello, World !"
After entering the node, you can enter:
1 |
Console. log ("Hello, World! "); |
Then we will see the output in the command line: Hello, World!
Next, let's test whether node. js can run correctly.
For example, create a node folder under drive D, create a test. js folder, open test, and enter the following code in js:
123456789 |
Var http = require ("http"); http. createServer (function (req, res) {res. writehead( 200, {"Content-Type": "text/html"}); res. write ("Node. js "); res. write (" Hello World "); Res. end ("Beyondweb.cn ") ;}). Listen (3000); console. log (" HTTP server is listening at port 3000 ."); |
Then open the command line to enter your test. js directory, and then execute: node test. then open the browser and enter the address http: // 127.0.0.1: 3000/or http: // localhost: 3000 in the browser to run the testjs file.
The running effect is as follows:
OK. If there are no errors, the installation is complete.
This article was originally created by BeyondWeb.cn. If you need to reprint it, please use hyperlink to indicate the source: frontend development -BeyondWeb.cn