Monday 7 November 2011

Installing node.js on windows 7 machine

Ive recently been looking for instructions on how to install node.js (the javascript powered web server) on windows, and it received some quite confusing answers involving cygwin, building things from source etc.
And yes it is possible to install node on windows 7, in fact.... Its really really easy actually.

1. download node.exe from http://nodejs.org/dist/v0.6.0/node.exe (link avaliable from http://nodejs.org)
2. create a sample node app

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');


save in a file 'example.js' and place in the same folder as node.exe (anywhere on your system)
open a command prompt in the folder with node.exe and your .js file

run > node example.js
and thats it, now open your browser and goto: http://127.0.0.1:1337/

Hello World

how easy was that?

1 comment:

  1. Comments Added to Reddit.com

    [–]FryGuy1013 1 point 2 days ago
    You miss out on npm though doing it this way in my experience.

    [–]insin 4 points 2 days ago*
    Put node.exe in \node\bin\
    Add \node\bin\ to PATH
    git clone --recursive
    git://github.com/isaacs/npm.git
    node cli.js install npm -gf

    [–]bornemix 1 point 1 day ago
    But no native extensions... :-(

    ReplyDelete