My Software Notes

Useful things I discover

Installing npm (Node Package Manager) on Windows

with 4 comments

A while ago I tried and tried and tried and tore out my hair trying to install npm on Windows (in case you’re new to node-js, npm is the Node Package Manager – sort of a NuGet for Node).

I followed the instructions but I got all sorts of annoying errors that I just could not get around no matter what I tried.  So I gave up.

A couple of days ago I saw that there was a nice looking book called “Node for Front-End Developers” that looked like it didn’t need any packages installed, so I bought it and decided to get the latest version of Node.  I went to the Node website and there on the home page was a download button that popped up a choice of Node versions for Windows, Mac or any other platform (by getting the source and building it yourself).

I ran the Windows installer and (hoo-friggin-ray!) it installed npm at the same time.

The new installer is nice and simple – it just runs and installs Node.  What more can you ask for in an installer?  (Well, maybe giving the choice of where to install Node would be good, in case you don’t want to put it in “c:\program files”.)

One gotcha about running npm in Windows 7 – if you are installing something globally, you must run npm as an administrator because it is under “c:\program files” and any changes you want to make in that area require admin privileges.

Anyway, I got started on the book, which is very hands-on, and I’m learning more and more about Node.

I’ll blog more about it as I discover the wonders of JavaScript on the server.

Advertisements

Written by gsdwriter

February 7, 2012 at 2:33 pm

Posted in JavaScript, node.js

Tagged with ,

4 Responses

Subscribe to comments with RSS.

  1. I’m using node and npm on windows and I find that when I say npm install -g foo, it puts the module in a very stupid place – C:\users\\AppData\Roaming\etc.etc. instead of under my node installation. Is there some environment variable that needs to be set?

    humanbean

    June 8, 2012 at 12:04 pm

    • If you run npm in the folder of your project then it should install the package in the appropriate location under your project folder, rather than under the AppData folder.

      There’s an example here (http://www.emadibrahim.com/2011/11/07/nodejs-on-windows/) at step 4.

      And there’s another example here (http://weblogs.asp.net/shijuvarghese/archive/2012/05/26/developing-and-deploying-node-js-express-web-app-on-windows-azure.aspx) under the “Install Express and Jade Modules” section.

      gsdwriter

      September 3, 2012 at 12:48 pm

      • Note humanbean was asking about installing a module *globally* via the -g flag, which by design does not install to the local project folder but to a special (OS-specific) location for global packages. On Windows, that special place is indeed “C:\users\\AppData\Roaming\npm\…” which is bad enough, but it also doesn’t use a “\bin” directory like OSX does, making it even stranger.

        Node on Windows is possible but painful (as I’m learning the hard way in developing a cross-platform module for lessc with filesystem watching).

        cweekly

        November 14, 2012 at 3:03 pm

    • Hi humanbean,
      That “-g” flag is very important. It says “install this module *globally*”. If you omit it, you’ll see the expected behavior of installing the module locally to your project directory. However, for CLI programs (i.e. something you execute on the command line), you need to install them globally.

      In general node is way friendlier and easier on OSX than on Windows…
      Good luck!

      cweekly

      November 14, 2012 at 3:06 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: