Install nodejs environment variable settings in windows and nodejs Environment Variables

Source: Internet
Author: User

Install nodejs environment variable settings in windows and nodejs Environment Variables

You need to set two directories for adding node.exe to path2.C:\Program Files\nodejsAdd the environment variable NODE_PATH with the valueC:\Program Files\nodejs\node_modules

1. Download

Go to nodejs to download the node. msi installation package, which contains node. js and npm;

Double-click node. msi and select the installation path and npm;

 

Ii. Set Environment Variables

[No environment variables need to be designed for the new version, and the software will automatically write the environment variables]

Right-click a computer (or my computer) and choose Properties> advanced system Settings> environment variables.

Create a user variable.

Variable name: NODE_PATH

Value: C: \ Program Files \ nodejs \ node_modules

Note: The value is the nodejs installation directory.

Iii. Test

1. Write the test code test. js.

Find a project folder and create a new service folder. My directory is E: \ nodetest \ service.

Note: The path cannot contain Chinese characters.

Create a new UTF-8 code js file, file name casually, my file is called test. js

Add the following code to the js file:

var http=require('http');http.createServer(function (request,response){  response.writeHead(200,{'Content-Type':'text/plain'})  response.end("hello,world\n");  }).listen(8887);  console.log('Server runing at http://127.0.0.1:8887');  

2. Run

Start the nodejs service, press the window key + R, Enter cmd, and press Enter.

In the command line window, enter node E: \ nodetest \ service \ test. js

Note: No extra points are added at the end;

Successful

Enter http: // 127.0.0.1: 8887/in the browser and the result is as follows.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.