Installing node via site vs brew

I have found a caveat, it looks like when i installed node.js via the site(node.js), I ran into permission issues. Trying to use the “npm install -g npm@latest” would kick errors and then make basically stop working. Im on Mac OSX.

However, when i reinstalled it via brew, I’ve had no issues since. Could it be a permissions problem on the users end?(i.e. the package installs differently?)

I know this has been discussed before, but I dont think anyone has mentioned this before as a solution.

In order to globally install something like that, you would need to do it with sudo privileges. That’s why you’re getting permission errors.

The correct way to do that would be sudo npm install -g npm@latest

Not sure why that works via brew, but brew probably installs it in a place you have full writable privileges to.

No no no, please never install node using sudo, it can cause a bunch of problems down the road.

We recommend using nvm or homebrew to keep node working and up to date.

Yep, that’s exactly why!

2 Likes

Yea, thats what i think happens (uses sudo) when it installs it via the package from the node.js site, at least on mac osx.

Yep, that’s definitely the truth.

I ended up in nightmare land over this and it stopped me for a while from doing pretty much anything command line related. It was a never ending downward spiral of failed installs and sudo everything. I thought the whole thing was ridiculous and had no idea why anyone would ever leave the safety of a GUI like CodeKit for the command line. I knew something was off on my end, and I finally decided to get it sorted out.

I ended up completely uninstalling and reinstalling node. I was going to go the home brew route but read something, somewhere, that counseled against this. I really don’t remember what the reason was and I don’t know if it was valid or if I saved the link.

I do have homebrew installed, but I installed node using the node install package, and followed this method for getting permissions issues sorted out and everything has been smooth sailing since.

That’s just my experience, but I highly recommend hitting that link and checking the video out.

1 Like

It would be interesting to read the article that was against Homebrew. I’ve never had any issues with it myself and it’s come in useful a couple of times with ansible to rollback to working versions:

brew info ansible # This lists previously installed versions
brew switch ansible 1.9.0.1 # This switches to the previously install working package
1 Like

I don’t believe there was an article that suggested against it, just comments I ran across on various sites while trying to get my particular mess sorted out.

Again, I’m not saying that any of the concerns were valid or that installing via Homebrew is a bad idea, but I was at such a point of frustration with my set up that I didn’t want to take any chances.

I looked at all the node related pins I have in my pinboard account, and this is the only relevant thing I could find - https://gist.github.com/DanHerbert/9520689

1 Like

Everyone just use nvm and then thank me for the good advice :sunglasses:.

1 Like

What I had to do (after headaches and nightmares and a level of fear related to npm), was first uninstall node and npm, delete all the folders, and so forth. Then, install node with homebrew, using:

brew install node --without-npm

Then I used this guide to install npm without sudo: http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/

Then, check that it worked with : npm install -g npm@latest

Its been smooth sailing so far, so I’m pleased with the workflow.

1 Like

Sure, the biggest thing to keep in mind is not using sudo, as that’s the short trip to all sorts of permission problems. However, the beauty of using nvm is that you can install and use any version of node and npm you want, as well as avoiding sudo. Makes life a lot easier overall

Anyone tried installing NVM using brew? http://brewformulas.org/Nvm

1 Like

Those caveats tho. Mind as well just install manually lol.

1 Like