Node.js Part 2: Getting MEAN

This is the second post in my series of getting started with Node.js.  

In my last post, I installed Node.js on both my Windows 7 machine and my Macbook Pro.  My next step was to get started building a static website for one of my domains.  Mark Drew suggested getting started with using the MEAN stack - Mongo DB, Express, Angular and Node. I had looked at MEAN before really getting started, and I agree that it's probably the best stack for me, so I went to and followed the install instructions right there on the home page.  That's where I ran into my first issue.

Let me start by saying, I'm a recent Mac convert.  I don't foresee ditching my Windows machines because I'm so heavily invested, but I do want to get up to speed on OSX/Unix as well because it's so useful.  With that said, I opened my command line on my Windows 7 machine and ran "sudo npm install -g mean-cli" which gave me the response "'sudo' is not recognized as an internal or external command, operable program or batch file."

After a quick message to Mark, he tipped me off that "sudo" is an OSX command to run an operation as an administrator.  Therefore, it doesn't apply on my Windows machine and I should just leave out the "sudo" part of the command.  Whew!  Easy enough!  So I went back to the command line and ran "npm install -g mean-cli". 

That clearly got the ball rolling, however there were LOTS of errors.  Fortunately the error output was readable - MEAN was looking for a more recent version of NPM (2.x). I thought that was odd since I just installed Node, so wouldn't it stand to reason that I actually had the most recent version of NPM? Apparently not.  Running "npm -v" in the command line returned "1.x".  So I figured it would probably be pretty easy to update NPM with a simple command.  Indeed, I found "npm install npm -g" which didn't work, and "npm update -g" which also didn't work.  So, more Googling led me to the NPM docs on Github which told me that I had a couple options for upgrading to version 2.x of NPM.  I chose to modify the PATH to fix the issue.  Here's how do that:

Click the Start menu and search for "environment variables".  You'll see options to edit the environment variables for either your account or for the system.  I chose to edit the system variables because I'm the only user on my machine anyway.  That opens the System Properties window.  Click the Environment Variables button and you'll see this:

System Variables

Select the Path variable and click Edit.  Before the last entry (they're separated by semicolons) add the following: "C:\Users\[Your user account name]\AppData\Roaming\npm\;" - obviously substituting [your user account name] for whatever your user name is when you log onto your machine.  This will change the priority of where windows looks for NPM.  I restarted my computer for good measure, and wouldn't you know it... running "npm -v" gave me 2.1.17.   Woot!  Ok, so now I can get on with installing MEAN.  Finally.  Or so I thought.

Once again, I ran "npm install -g mean-cli" in the command line and this is what I got:

NPM Install Error

I put it out to Twitter, and got a few responses.  The best lead I got was this article on Stack Overflow from Todd Rafferty.  I followed the instructions to the letter, but still no luck.  Other folks chimed in that they had similar experiences with Node on Windows and never got past them.  Not too encouraging I must say.

I decided to take a break from the Windows 7 install and try my luck with my Macbook Pro.  Sadly, it was completely painless and installed without any issues whatsoever.  

At this point I don't want to continue until I can reach the same point on my Windows computer.  I know the Apple fanboys will just tell me to move on, but I'm stubborn, and I will try to find a way to coax it.  

  1. Rick Mason

    #1 by Rick Mason - January 7, 2015 at 1:40 PM


    Here's what worked for me on Windows 7:

    Navigate to C:\Program Files\nodejs\ in the command prompt and then run the installation without the global flag:

    npm install npm

    Detailed on this website:
  2. Kris

    #2 by Kris - January 7, 2015 at 1:47 PM

    Thanks Rick, I'll check it out and report back!
  3. Denis Afonso

    #3 by Denis Afonso - January 9, 2015 at 9:47 AM

    Have a look at cygwin and vagrant.
    That's what I use on my windows machine and it helped me avoid most of these problems.
(will not be published)
Leave this field empty: