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.

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

  1. sandeep says:

    npm ERR! network
    npm ERR! network If you are behind a proxy, please make sure that the
    npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

    npm ERR! Please include the following file with any support request:
    npm ERR! D:\study\node\nodejs\npm-master\npm-debug.log

    Am getting this error, please let me know how can i overcome.
    I have configured proxy by creating environment variable ‘http_proxy’.
    How can i verify, any clue ?


  2. sandeep says:

    npm install express -g
    ‘npm’ is not recognized as an internal and external command,opearble program or batch file.

    Am getting above error besides of a lot of search am not able to fix it.
    If you could hint me, that will be great !

  3. Captain says:

    Node development on Windows can be pretty tricky sometimes. Restarting your system might help.

Make a Comment