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.
The author starof, because the knowledge itself in the change, the author is also constantly learning and growth, the content of the article is not updated regularly, in order to avoid misleading readers, convenient tracing, please reprint annotated source: http://www.cnblogs.com/starof/p/5194716. HTML has a problem welcome to discuss with me, common progress.
NODEJS Environment Configuration under Windows