To update npm , you need to run npm update npm -g . Where -g stands for global.
Knowing that if you want to update the global packages installed on your system, you run npm update -g
If you did not add -g when running npm update , it will try to update the local node packages (also known as your current $PWD directory). To find out if you have packages installed in the local directory, you can run npm list , which will return the following if none of them are installed.
/your/current/directory/ βββ (empty)
If you have node packages in this folder, you will see something like this. (note: This is what was returned when I ran npm list -g )
/usr/local/lib βββ¬ npm@1.4.7 βββ abbrev@1.0.4 βββ ansi@0.2.1 βββ ...
You can also run brew update && brew upgrade && brew doctor to make sure everything is up to date.
My advice on the first question is to use brew , because it will save you a lot of headaches in the long run, because it can manage almost everything that you install on your computer. Take a look at https://github.com/nicolashery/mac-dev-setup to find out how they set up their development computers.
Make sure you look at https://github.com/phinze/homebrew-cask so you can install applications through brew cask <app you want> .
The biggest reason to use brew for node is that it installs nodes and npm at the same time, it uses the path $(brew --prefix) , but still has its place in /usr/local/ . You still use the same commands as you if you install it through the installation of the package. However, you can really remove node and npm by simply running brew uninstall node , which you cannot do with other ways to install it.
Hope this helps.
PS: If you already have a node installed in another way, then sudo chown $USER /usr/local/* is your friend. All this allows you to read and write access to all folders and files in /usr/local/ , which are necessary only to fix links for brew.
tjbenton
source share