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.

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

  1. Miguel says:

    Hello Isaac.

    On trying to install npm, following the steps that you post here, I couldn’t finish the process.
    Let me show you my verifying steps with the Ok finish.

    ——
    1st.: I downloaded and installed Git.
    2nd.: I restarted the machine.
    3rd.: MD node on root c:\.
    4th.: I downloaded “node.exe” and copy to “c:\node”.
    5th.: I run Git Shell.
    6th.: I followed your sted as described bellow:
    ——-
    C:\node> git config –system http.sslcainfo /bin/curl-ca-bundle.crt (OK)
    C:\node> git clone –recursive git://github.com/isaacs/npm.git (OK)
    C:\node> cd npm (OK)
    ——-

    7th.: I restart my machine, again.

    8th.: Then, on doing the last step, something was going wrong!
    It can’t recognize the command line!!
    It happend this:

    ——
    C:\node\npm [master]> node cli.js install npm -gf
    “The term ‘node’ is not recognized as the name of a cmdlet, function, script fil
    e, or operable program. Check the spelling of the name, or if a path was includ
    ed, verify that the path is correct and try again.
    At line:1 char:5
    + node <<<
    —–

    What I do wrong?
    Do I miss doing something?

    Thanks in advance.

  2. Miguel says:

    Here is the comple instroction of the error on the last step:

    —–
    C:\node\npm [master]> node cli.js install npm -gf
    The term ‘node’ is not recognized as the name of a cmdlet, function, script fil
    e, or operable program. Check the spelling of the name, or if a path was includ
    ed, verify that the path is correct and try again.
    At line:1 char:5
    + node <<<

    —-

  3. Miguel says:

    Sorry!!
    There is the complet instrution…:
    —–
    C:\node\npm [master]> node cli.js install npm -gf
    The term ‘node’ is not recognized as the name of a cmdlet, function, script file,
    or operable program. Check the spelling of the name, or if a path was included,
    verify that the path is correct and try again.
    At line:1 char:5
    + node <<<
    —-

    Thanks in advance.

  4. Miguel says:

    Ups…!!
    Sorry again…!!
    Here’s the rest … :

    “At line:1 char:5″
    “+ node <<<”

    ;)

  5. Miguel says:

    Dam…!!
    I don’t know why my posts can’t show the rest os the error instructions…!?!? :(
    I try to type it as well but is nor showing… :s

    So, on your response to my essue problem,
    if you pass me your email, I will send you an image file so you can see it.

    Thank you once again. ;)

  6. Asad says:

    hey,thanks for these steps it works for me…but i am still getting an error when i run hello.js from my desktop it shows……………..
    C:\Users\Asad\Desktop>node
    > hello.js
    ReferenceError: hello is not defined
    at repl:1:2
    at REPLServer.self.eval (repl.js:110:21)
    at Interface. (repl.js:239:12)
    at Interface.emit (events.js:95:17)
    at Interface._onLine (readline.js:202:10)
    at Interface._line (readline.js:531:8)
    at Interface._ttyWrite (readline.js:760:14)
    at ReadStream.onkeypress (readline.js:99:10)
    at ReadStream.emit (events.js:98:17)
    at emitKey (readline.js:1095:12)
    >
    ……………………………………………..
    C:\Users\Asad\Desktop>node hello.js

    module.js:340
    throw err;
    ^
    Error: Cannot find module ‘C:\Users\Asad\Desktop\hello.js’
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

    whats wrong with this please help me.
    all i have install correctly but why it does not run…

    C:\Users\Asad>node -v
    v0.10.31

    C:\Users\Asad>npm -v
    1.4.23

    git ,cygwin also installed
    please guide me as soon as possible…Thanks in adance.

  7. Breen Whtiman says:

    Sorry, Feb 2015 and still get npm unrecognized on a fresh node install on a fresh machine.

    Node/npm is borked.

  8. mayank says:

    unable to install trying to use npm install express -g
    these are my output on command prompt…what sd I do ?

    C:\Program Files\nodejs>npm install express -g
    npm http GET http://registry.npmjs.org/express
    npm http GET http://registry.npmjs.org/express
    npm http GET http://registry.npmjs.org/express
    npm ERR! network getaddrinfo ENOTFOUND
    npm ERR! network This is most likely not a problem with npm itself
    npm ERR! network and is related to network connectivity.
    npm ERR! network In most cases you are behind a proxy or have bad network settin
    gs.
    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! System Windows_NT 6.2.9200
    npm ERR! command “C:\\Program Files\\nodejs\\\\node.exe” “C:\\Program Files\\nod
    ejs\\node_modules\\npm\\bin\\npm-cli.js” “install” “express” “-g”
    npm ERR! cwd C:\Program Files\nodejs
    npm ERR! node -v v0.10.28
    npm ERR! npm -v 1.4.9
    npm ERR! syscall getaddrinfo
    npm ERR! code ENOTFOUND
    npm ERR! errno ENOTFOUND
    npm ERR! Error: EPERM, open ‘C:\Program Files\nodejs\npm-debug.log’
    npm ERR! { [Error: EPERM, open ‘C:\Program Files\nodejs\npm-debug.log’]
    npm ERR! errno: 50,
    npm ERR! code: ‘EPERM’,
    npm ERR! path: ‘C:\\Program Files\\nodejs\\npm-debug.log’ }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! System Windows_NT 6.2.9200
    npm ERR! command “C:\\Program Files\\nodejs\\\\node.exe” “C:\\Program Files\\nod
    ejs\\node_modules\\npm\\bin\\npm-cli.js” “install” “express” “-g”
    npm ERR! cwd C:\Program Files\nodejs
    npm ERR! node -v v0.10.28
    npm ERR! npm -v 1.4.9
    npm ERR! path C:\Program Files\nodejs\npm-debug.log
    npm ERR! code EPERM
    npm ERR! errno 50
    npm ERR! stack Error: EPERM, open ‘C:\Program Files\nodejs\npm-debug.log’
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR! C:\Program Files\nodejs\npm-debug.log
    npm ERR! not ok code 0

    C:\Program Files\nodejs>

  9. Hari Prasanth says:

    When I try to install functional.js I get some error.

    npm ERR! Windows_NT 6.3.9600
    npm ERR! argv “C:\\Program Files (x86)\\nodejs\\\\node.exe” “C:\\Program Files (
    x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js” “install” “express” “-g”
    npm ERR! node v0.12.0
    npm ERR! npm v2.5.1
    npm ERR! code ENOTFOUND
    npm ERR! errno ENOTFOUND
    npm ERR! syscall getaddrinfo

    npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org
    npm ERR! network This is most likely not a problem with npm itself
    npm ERR! network and is related to network connectivity.
    npm ERR! network In most cases you are behind a proxy or have bad network settin
    gs.
    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! Windows_NT 6.3.9600
    npm ERR! argv “C:\\Program Files (x86)\\nodejs\\\\node.exe” “C:\\Program Files (
    x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js” “install” “express” “-g”
    npm ERR! node v0.12.0
    npm ERR! npm v2.5.1

    npm ERR! Uncaught, unspecified “error” event.
    npm ERR!
    npm ERR! If you need help, you may report this error at:
    npm ERR!

    npm ERR! Please include the following file with any support request:
    npm ERR! C:\Program Files (x86)\nodejs\npm-debug.log

Make a Comment