Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Npm update use brew or npm on OSX?

The treehouse npm install guide for OSX uses brew to install npm. However the npm course suggests using npm to update itself. If we're using OSX shouldn't we be using brew to update npm too, as it was installed via brew?

1 Answer

I see your logic, and it's a bit off. Let me explain.

NPM is a package manager. Meaning that I use it to install packages for my app. In order to use npm, I can install it via brew. Once I have npm, I can use it to install packages globally, locally with the -g or --save during an npm install when getting packages I want to use in my app. npm update, updates the packages managed by npm. the packages installed via npm are not managed by brew. They are managed by npm and Brew knows nothing of the packages you installed with npm. npm will make sure you have the latest versions of the packages you are using in your app.

Now, you can also update npm with brew. Brew pulls npm from a repository. Say you wanted to use a beta version of npm that wasn't in the brew repository yet? You could use npm to update it'self. Or you could install different versions of npm for different projects. Let me ask you this, if npm can update itself. Why does brew have to update it for me? I wouldn't use brew to update my version of npm if npm can do it itself.

Does that makes sense?

Thanks, the first paragraph I was clear on, it was the second part of your response was what I was trying to understand. Without knowing the internals of how brew and npm work. Brew may have installed npm is a way unique to brew (that wasn't comptabile with the method npm uses).
but from your asnwer it sounds like it works like brew, python and pip. I use brew to install python globally or to usr/local (inc pip if python 3) and then use pip to update itself either globally or for each virtualenv (project). Thanks got it now.