Install Node.js and NPM on Windows
How to install Node.js and NPM 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.
jesus, I just got a mac so that I can use Node and now it’s on Windows? I mean it’s great! Does “everything” work now on Windows as it does on a mac?
Hey Nik, I highly recommend using a *nix with Node. So your Mac is worth it. If you have a Linux or Mac machine, don’t bother with Windows. Node and it’s modules are still a little rough on Windows because Node was developed for *nix to begin with it. If you just want to use Node without any modules (even built-in modules), Node on Windows works as good as on Mac, but if you use modules, you will start to realize Node is not meant for Windows (as of now). Congrats on your Mac!
got git
got npm
when I run the following
npm install jade
windows spins and then i get an alert telling me that node has expired and windows is looking for a solution
also in your instructions the directory should show c:\node\npm
tried npm install stylus
Fatal error – js allocation failed – process out of memory
Hi Alnoor, c:\node\npm is only for git. You should forget it exists when using npm. Don’t cd to the npm dir and install stuff there. Call npm from C:\node only.
Please, I have this Error..!!!!!
Help me… !!!
myPc@MYPC-PC /c/node/npm (master)
$ npm install express
sh.exe”: npm: command not found
jardix, follow the instructions I posted in the article, it should work.
I got the following error:
T:\tmp>git config –system http.sslcainfo /bin/curl-ca-bundle.crt
error: could not lock config file /usr/etc/gitconfig: No such file or directory
after I created the /usr/etc dir under cygwin, that error gone,
but later on when I clone npm I got another error:
Cloning into node_modules/abbrev…
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing https://github.com/isaacs/abbrev-js.git/info/refs
fatal: HTTP request failed
Clone of ‘https://github.com/isaacs/abbrev-js.git’ into submodule path ‘node_modules/abbrev’ failed
Did I miss something?
@Green, Node officially recommends NOT USING cygwin.
Node 0.6.1 is available as an msi installer – http://nodejs.org/dist/v0.6.1/node-v0.6.1.msi please use it instead.
If you want to try Node in its FULL glory download VirtualBox and install Ubuntu on it.
How do you install NPM if you use the MSI installer?
@Rinie, first make sure you can access node from the command line (confirm with
node -v). You may need to restart, if you can’t. If you still can’t do this:C:\node> set path=%PATH%;C:\Program Files\nodejsC:\node> setx path "%PATH%"
Then create the
C:\nodedirectory and follow the procedure normally. The only difference is that this time node.exe does not reside atC:\node, but atC:\Program Files\nodejs.hi
excellent guide
bat when I try to install Express npm gives me this error:
npm ERR! cb() never called!
npm ERR!
npm not ok
from what could be caused?
I have the same problem as Mirco has>
D:\node\npm>node cli.js install npm -gf
D:\node\npm -> D:\node\node_modules\npm\bin\npm-cli.js
D:\node\npm-g -> D:\node\node_modules\npm\bin\npm-cli.js
D:\node\npm_g -> D:\node\node_modules\npm\bin\npm-cli.js
npm@1.0.106 D:\node\node_modules\npm
D:\node\npm>cd ..
D:\node>npm install -g express
npm ERR! cb() never called!
npm ERR!
npm not ok
Any ideas?
Hi this is nice ,
but I also have some error while trying to
“npm install express -g”
any help will be great,
Thanks
cb() never calledis a rare bug in npm. Make sure you are using the latest version of npm. Reinstall npm once just for confirmation.I did it from scratch (newest node, newest npm cloned):
Whatever I installed I get:
D:\node>npm install html2jade -g
npm ERR! cb() never called!
npm ERR!
npm not ok
Most likely a bug in npm. Consider filing a bug report.
Also I would suggest playing with Node.js on a Linux system. Ultimately you are going to be hosting your Node app on a Linux system, most probably. Check out VirtualBox (https://www.virtualbox.org/).
I have files a few now. But I am sick of debugging. There is plenty of things to debug on my side.
Yup, I already jumped on Linux.
Thanks!
It actually works! don’t let the message fool you!
npm install express
you get the error
npm ERR! cb() never called!
npm ERR!
npm not ok
do dir you’ll see express is installed in node_modules
Fazle, it isn’t properly installing and this is a known issue, you must install all dependencies before installing the full package. See GitHub ticket here: https://github.com/isaacs/npm/issues/1733
Use last version.
http://npmjs.org/dist/
When I write this code I didn’t get any answer:
var http = require(‘http’);
http.createServer(function (request, response) {
response.writeHead(200, {‘Content-Type’: ‘text/plain’});
response.end(‘Hello World\n’);
}).listen(8124);
console.log(‘Server running at http://127.0.0.1:8124/’);
I am using Windows XP
When I was installing npm I got this error
C:\npm>node cli.js install npm -gf
npm ERR! couldn’t unpack C:\DOCUME~1\PC\LOCALS~1\Temp
\npm-1322406942433\13224069
42433-0.9994336722884327\tmp.tgz to C:\DOCUME~1\PC\LOCALS~1\Temp
\npm-13224069424
33\1322406942433-0.9994336722884327\contents
npm ERR! Error: UNKNOWN, unknown error ‘C:/DOCUME~1/PC/LOCALS~1/Temp/
npm-1322406
942433/1322406942433-0.9994336722884327/contents/___package.npm/
package’
Could somebody help me:)
Thanks
@vikifor, Node now comes with NPM by default – http://nodejs.org/#download You don’t need to install NPM separately anymore.
Hi,
i just came across you blog… I used the node msi file and i got the npm running from it
problem is i execute the following command but, it do nothing …
C:\anix> npm install express -g
npm http GET https://registry.npmjs.org/express
i should have downloaded ans install express if i am not wrong but nothing happen after that line and nor my internet is accessed by this code… no idea what is the issue .. or is it some kind of permission issue for npm ?
let m know if u can help me out in any ways…
Thanks,
Anix.
Hi Anix, make sure you are are running the command prompt as Administrator for all -g modules. It could also be a problem with the NPM website, it has downtimes sometimes, try again later.
A tip for Express: when you create a project, you may be shown some errors about missing folders, re-execute the command again to create the project successfully.
Hi,
Thanks for the information. I’ve installed node and express on my windows XP system (sp3) and I can run node, but when I try to run ‘express’ it just hangs there. I’ve tracked it down to within mkdirp. When it tries to resolve the path for where the app will go, its using backslashes, and it seems that mkdirp is looking for forward slashes. In other words:
c:\home\nrutta\www
oops, got cut off:
c:\home\nrutta\www> express app
resolving path “c:\home\nrutta\www\app” …
Note that the above is a console.log message I put into mkdirp. So my questions are:
1. is this supposed to work on windows xp?
2. I’m assuming this should be run from a dos shell (for example?)
3. has anyone else seen this problem, and do I possibly have something
messed up on my system (I do have cygwin installed).
Any help will be appreciated.
Neal
I just Installed node.js v0.6.10 on windows through msi installer. I can access node from anywhere on command prompt. I have installed socket.io through npm. now the problem is, in my code has var io = require(‘socket.io’); when i try to run that file, getting – Error: Cannot find module ‘socket.io’. how can I fix this without changing the code?
@Pilot, try doing
npm install socket.ioagain. Might fix it.Hi,
I tried running the test.js but I keep getting the error below. I’ve run npm install connect, and also npm install mime.
Thanks for your time.
node.js:201
throw e; // process.nextTick error, or ‘error’ event on first tick
^
TypeError: Cannot read property ‘prototype’ of undefined
at Object. (c:\nodejs\node_modules\express\lib\http.js:49:35)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object. (c:\nodejs\node_modules\express\lib\https.js:13:18)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
Thank you!!
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
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.
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.