I am Hack Sparrow
Captain of the Internets.

Install Node.js and NPM on Windows

How to install Node.js and NPM on Windows

UPDATE Feb 1, 2012: This article is fairly outdated now. Node.js installs right into the Windows system now, no need for moving files, setting path etc. If Node path is not detected, do a restart.

UPDATE: NPM now comes bundled with Node.js which can be installed using an MSI - get it here. No more headache of installing NPM separately on Windows.

Well, Node is not very Windows-friendly as of now; meaning - getting Node.js and npm working on a Windows machine is not as easy and straightforward as it is on a Linux machine. But worry not, getting a working Node environment is not that difficult either. I will show you the easy way, if you looking for installation from from source etc, look somewhere else.

Node.js on Windows

Getting Node on Windows is very easy, just download the node.exe binary from node.org. It's about 4.9 MB, doesn't take much time. Once downloaded, move node.exe to C:\node\node.exe, cd to C:\node, and do the following:

C:\node> set path=%PATH%;%CD%
C:\node> setx path "%PATH%"

The above commands set up Windows such that you can call node from anywhere in the system.

NPM on Windows

The npm dude is supposedly working on a one-line npm installer for Windows like we have for Linux. Till that's done the following is how you get npm working on a Windows machine.

Important: you might have thought / heard of manually downloading node modules, including npm itself, and getting them to work with Node. I tried manually installing npm from it's zip download but ended up with "Cannot find module 'graceful-fs'". Turned out, all the directories under node_modules were empty! Dependencies and all the hassle, working that way is a pain the ass and you will only end up wasting your time, so don't bother.

If you don't have Git installed on your system, the first step to installing npm on your system is installing Git. It's worth it, it will come handy in future for many other projects to, so go ahead download Git for Windows and install it.

I thought the Git installer would be smart enough to set the environment variables for the current session, but it didn't. You have to restart your computer to get Git working properly.

Once you have restarted you system and gotten Git working, cd to C:\node, and do the following:

C:\node> git config --system http.sslcainfo /bin/curl-ca-bundle.crt
C:\node> git clone --recursive git://github.com/isaacs/npm.git
C:\node> cd npm
C:\node> node cli.js install npm -gf

The cloning process takes some time, so be patient. Once you have installed npm, try installing a Node module, say express.

C:\node> npm install express -g

So that's it! That's how you get Node.js and npm working on your Windows machine. If you encounter any problem while installing them the way I described, ping me in the comments.

34 Responses to “Install Node.js and NPM on Windows”

  1. Benny Neugebauer says:

    Thank you!!

  2. undertaker says:

    Thank you very much about such wonderful topic\

    still need help please

    every thing was ok until this step “node cli.js install npm -gf”

    I have got this list of errors masseges

    http://img513.imageshack.us/img513/486/17069751.jpg

    can you help me with that please ?

    thanks and regards

    UnderTacker

  3. anix says:

    i was trying a socket io sample from internet but i has asked me for redis module.
    but npm is unable to install it on radis mobile.

    is radis available for windows or only for linux platform.

  4. Captain says:

    Hi anix, Redis is officially not supported on Windows, but there efforts to bring Redis to Windows – http://redis.io/download. Use VirtualBox to install Ubuntu and play around in a more developer friendly environment.

Make a Comment