install Nodejs on windows8

This article is about how to install a Nodejs Server on Windows 8 . also work on win7.

First,we download a nodejs msi file from its Homepage, the

website auto identify your os type;If your sys version is x64,then the download url may be like

open the msi file and click NEXT all the way.

open your cmd window, type in "node -v" to check if you install it right;

It should return a string "v0.10.15";

After the install step, a path named "C:Program Filesnodejs" has been added to you PATH item in envionment variables;

Now we can use to try our first Nodejs program

Create a js file anywhere you like named "node1.js";

type in these strings below:

This sip web server written in Node echo "It works" for any request:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('It worksn');
}).listen(2333, '');
console.log('Server running at');

right click your mouse button,select "open cmd here", then

execute it with the node program from the command line:

node node1.js

this step returns the message: Server running at

Use your browser to access the above url.

This is very simple, isn't it?


转载:转载请注明原文链接 - install Nodejs on windows8