NODEJS Environment Configuration under Windows

Source: Internet
Author: User

First, download

Go to Nodejs to download the Node.msi installation package, which contains node. js and NPM;

Double-click on the Node.msi, select the installation path and NPM;

Second, set environment variables

[The new version does not need to design environment variables, the software will automatically write environment variables]

Computer (or My Computer) right-click the Properties-"Advanced system Settings-" environment variable.

Create a new user variable.

Variable name: Node_path

Value: C:\Program files\nodejs\node_modules

Note: The value is Nodejs installation directory

Third, test 1, write test code Test.js

Find a project folder, then create a new service folder, my directory is E:\nodetest\service

Note: This path cannot have Chinese

And then create a new UTF-8 encoded JS file, file name casually, my file is called Test.js

Add code into 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. Operation

Start Nodejs Service, window key +r, enter CMD and return

Enter node E:\nodetest\service\test.js in the Command line window

Note: End without semicolon;

Success

Enter the http://127.0.0.1:8887/results in the browser as follows.

Original address: http://www.cnblogs.com/starof/p/5194716.html

NODEJS Environment Configuration under Windows

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.