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