Saving the world one blog entry at a time

Installing node and npm on my Mavericks MacBook Pro

Package management is great. Yes, it is… WHEN IT WORKS. At least that was my attitude before.

As I anticipate release of Zurb Foundation 5 on November 21st, I couldn’t wait for it to go live. So, I decided to peak into their github branches. They are using Grunt in their process, and Foundation will be included in bower. And documentation is built with Grunt using assemble.io. OK, those things are things that I have not have time to play with. I hear all the good things that node.js and its npm installed application can do… a lot of it like magic, they say. I just have never done it, partly because I was using Red Hat’s rpm when it went from Red Hat to Fedora and it stop working, and more recently, something went wrong with ruby version control RVM thing.

I am still a designer-turned-himself-into-developer, and even with all of my geekiness, still don’t quite understand, or still have a fear, about “computer science”.

Anyway. I decided that the time is now. Just do it.

So, here are my notes while I struggled through it all. I will likely have to do it again when I get a new computer or anything like that. I figured it would be good to leave trace.

(Note: If you are here for “npm: command not found” problem, skip the middle part when I struggle with it and go to the end of the post for solution. It’s a permission issue and you need to run this: sudo chown -R $USER /usr/local)

I needed Bower, because with it, installing foundation would be a breeze. Done like this: bower install foundation

But, to get bower, I needed npm. Once I have npm, all I had to do was: npm install -g bower

That was easy. But wait. Making sure if I have node and npm, I tested by running command like which node; which npm; node -v; npm -v; which should print the path, and -v prints version number of installed applciations.

But I get this -bash: npm: command not found

Maybe I needed to do set $Path?export PATH="$PATH:/usr/local/git/bin:/usr/local/bin"
That was not it.

@mfncooper You were right. It was a permissions problem! No one had access to the file. Ran chmod on /usr/local/lib and set permissions to give full access to everyone. Then I ran the shell script again as a sudo user. Worked perfectly. Thanks.

What so, change the usr/local/lib permission? sudo chmod 777 /usr/local/lib/ then ran the pkg again.
Now when I do

That sets your user account as the owner of the /usr/local directory, so that you can just issue normal commands in there. Then you won’t ever have to use sudo when you install node or issue npm commands.

It’s much better this way. /usr/local is supposed to be the stuff you installed, after all.

Thank you good people of interwebz. Saved my day, yet again. Now I am off to Yeomaning, and then Grunting, then Bowering! (Whatever those things are!)

Enjoyed reading that. You describe a developers day well. Loading something like node/npm should be easier. It must have been easier at one point I had it installed. I think moving to Mavericks botched that and had to remove it. Now starting again.

This did not work. I entered this exact command: sudo chown -R $USER /usr/local
I entered my password, and then when I tried both sudo npm install -g bower and npm install -g bower I still got npm: command not found. What is the problem?