My first Nodejs program: Hello World
var http = require ("http"); Http.createserver (function (request, response) { Response.writehead (200, {") Content-type ":" Text/plain "}); Response.Write ("Hello World"); Response.End ();}). Listen (8000); Console.log (' Server is runing at http://127.0.0.1:8000 ');
Record the installation process:
- Go to http://nodejs.org/download/download the appropriate installation package, I downloaded this node-v0.10.0-x86.msi
- Create a Nodejs directory on your computer x disk and install the downloaded program into this directory
- Locate the PATH variable and add the X:\nodejs
- After adding PATH, create a new variable Node_path variable value X:\nodejs\node_modules
Here, even if the configuration is complete, create a new Nodejs folder in the D-disk, creating a Helloworld.js file in this folder to add the above JS content
Next click on the system's Start menu to run the cmd command:
D: d:\> CD Nodejsd:\>nodejs>node helloworld.js
Then appears: Server running at Http://127.0.0.1:8000/is successful.
Finally, open http://127.0.0.1:8000/in the browser.
Transferred from: http://iw3c.com/archive/my-first-nodejs-code-helloworld/