Angel \”Java\” Lopez on Blog

September 1, 2011

Playing With NodeJs (1) Running on Windows (and Azure)

Filed under: Azure, JavaScript, NodeJs — ajlopez @ 11:17 am

Up until some weeks ago, the only way to run NodeJs on Windows were to download it from the Git repo and compile it using CygWin (another case of get the bananas AND get the monkey).

Building node.js on Cygwin (Windows)
How to install Node.js on Windows

But now there is an alternative: NodeJs team has published a Windows pre-compiled version (0.5.4 and 0.5.5):

http://nodejs.org/#download
http://nodejs.org/dist/
http://nodejs.org/dist/v0.5.4/node.exe
http://nodejs.org/dist/v0.5.5/node.exe

(there is a new version http://nodejs.org/dist/v0.5.5/node-186364e.exe)

I’m using the 0.5.4. Let’s run a simple demo that use Socket.IO:

The Socket.IO module is missing. npm is the “standard” package manager for NodeJs, but there is no Windows version yet:

how can i do npm on windows!

So, you can download the module and its dependencies. See:

Node.js on Windows: Who Needs NPM?

Where are the URLs of the dependencies repos? You can look at

http://search.npmjs.org/

I downloaded some modules, this is my current setup:

These are subdirectories of the directory where node.exe resides. The key file to read in each module is its Package.json. This is the manifest of Socket.IO:

{
    "name": "socket.io"  , 
    "version": "0.7.9"  ,
    "description": "Real-time apps made cross-browser & easy with a WebSocket-like API"  ,
    "homepage": "http://socket.io"  , 
    "keywords": ["websocket", "socket", "realtime", "socket.io", "comet", "ajax"]  , 
    "author": "Guillermo Rauch <guillermo@learnboost.com>"  , 
    "contributors": [        
	{ "name": "Guillermo Rauch", "email": "rauchg@gmail.com" }      , 
        { "name": "Arnout Kazemier", "email": "info@3rd-eden.com" }      ,
        { "name": "Vladimir Dronnikov", "email": "dronnikov@gmail.com" }
     ]  ,
     "repository":{
	    "type": "git"      , 
        "url": "https://github.com/LearnBoost/Socket.IO-node.git"    
     }  ,
     "dependencies": {
        "socket.io-client": "0.7.9"      ,
        "policyfile": "0.0.4"      , 
        "redis": "0.6.6"    
     }  ,
     "devDependencies": {
        "expresso": "0.7.7"      ,
        "should": "0.0.4"      , 
        "assertvanish": "0.0.3-1"
    }  ,
     "main": "index"  , 
     "engines": { "node": ">= 0.4.0" }
}

When I had all the modules, I set the NODE_PATH variable and ran the app again:

Triumph of mind over matter! ;-) This was my first way. But the recommended alternative is to put all the modules in a node_modules subdirectory:

In this way, you don't need the NODE_PATH environment variable. I'm using NODE_PATH because I have my own modules under development in other directories. But if you have a node_modules subdirectory, NodeJs (>0.5 I guess) looks in that subdirectory for modules AND in NODE_PATH. Then I can use NODE_PATH=c:\Git where my AjFabriq module is under development. NodeJs will find Socket.IO in its node_modules subfolder, and my AjFabriq in c:\Git\ajfabriq.

If you have problems with dependencies, read @cibrax post:

Running the “Express” web development framework on Node for Windows

There is a Python clone of npm to install NodeJs packages.

There is a way to run NodeJs from IIS. Check @shanselman post:

Installing and Running node.js applications within IIS on Windows - Are you mad?

An interesting alternative in ASP.NET:

Asynchronous scalable web applications with real-time persistent long-running connections with SignalR

Well, and if you want to run NodeJs on Azure? Oh! I would like to write a post about that topic, but @ntotten have stolen my idea ;-). Read:

NodeJS on Windows Azure

Other posts about NodeJs and Azure:

Node.js, Ruby, and Python in Windows Azure: A Look at What’s Possible | MIX11 | Channel 9

http://channel9.msdn.com/Events/MIX/MIX11

Node.js, Ruby, and Python in Windows Azure: MIX Talk

http://blog.smarx.com/posts/node-js-ruby-and-python-in-windows-azure-my-mix-talk

Related posts about NodeJs:

Node.Js: Links, news, Resources (2)

Node.Js: Links, news, Resources (1)

Playing with Node.js, Ubuntu, Sqlite3 and node-Sqlite

My links:

http://www.delicious.com/ajlopez/nodejs

More playing with NodeJs is coming.

Keep tuned!

Angel “Java” Lopez

http://www.ajlopez.com

http://twitter.com/ajlopez

8 Comments »

  1. Wonder how they’ll get around npm packages which need a compiler (such as jsdom dependencies)

    Comment by RichB — September 2, 2011 @ 12:31 pm

  2. Thank you very much! I’ll be testing this now! Will report back when I hit some problems! ^_^

    Comment by Bangon Kali — September 2, 2011 @ 5:44 pm

    • To confirm my previous comment, I’ve made this 2MB package of NodeJS+MySQL+SocketIO for quick setup. Thank you once again for this very helpful post! http://j.mp/prB1Gm

      Comment by Bangon Kali — September 2, 2011 @ 7:37 pm

  3. [...] Detailed Coverage of Node Installation in Windows. Category: Developer / var addedComment = function(response) { //console.log('fbComments: Caught added comment'); //console.log('fbComments: Making AJAX call to update Facebook comment count'); $.post('http://blog.istoryahi.me/wp-content/plugins/facebook-comments-for-wordpress/facebook-comments-ajax.php&#039;, { fn: 'addComment', xid: 'Yn2LJaY0SsP7gc1_post118' }, function(resp) { if (resp === 'true') { //console.log('fbComments: Updated and cached Facebook comment count for post with xid=Yn2LJaY0SsP7gc1_post118'); } else { //console.log('fbComments: FAILED to update Facebook comment count for post with xid=Yn2LJaY0SsP7gc1_post118'); } }); }; FB.Event.subscribe('comments.add', addedComment); [...]

    Pingback by istoryahi.me » Node.JS Quick Setup — September 2, 2011 @ 7:30 pm

  4. [...] development. You can clone the repo in your node_modules folder if you are using NodeJs 5.x (see Playing With NodeJs (1) Running on Windows (and Azure)) [...]

    Pingback by AjFabriq on NodeJs (Part 2) A local Simple Application « Angel “Java” Lopez on Blog — September 8, 2011 @ 11:40 am

  5. [...] desarrollando. Pueden clonar el repo en el directorio node_modules donde está el NodeJs 5.x (see Playing With NodeJs (1) Running on Windows (and Azure), Jugando con NodeJs (1) En Windows (y en Azure)) [...]

    Pingback by AjFabriq en NodeJs (Parte 2) Una aplicación local simple - Angel "Java" Lopez — September 14, 2011 @ 5:33 am

  6. [...] Playing With NodeJs (1) Running on Windows (and Azure): A collection of Node.js resources for Windows & Windows Azure. [...]

    Pingback by Pie in the Sky (September 23, 2011) - MSDN Blogs — September 23, 2011 @ 9:59 pm

  7. Would you be interested in writing a commissioned article about Node.js on Windows Azure; approx. please contact me if you’re interested.

    Comment by Eric — May 22, 2012 @ 9:02 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 65 other followers

%d bloggers like this: