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

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 thoughts on “Playing With NodeJs (1) Running on Windows (and Azure)

  1. Pingback: istoryahi.me » Node.JS Quick Setup

  2. Pingback: AjFabriq on NodeJs (Part 2) A local Simple Application « Angel “Java” Lopez on Blog

  3. Pingback: AjFabriq en NodeJs (Parte 2) Una aplicación local simple - Angel "Java" Lopez

  4. Pingback: Pie in the Sky (September 23, 2011) - MSDN Blogs

  5. Eric

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

    Reply

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