Search code examples
macosnpmn

How to update npm permanently?


I'm trying to update npm from 2.15.11 to 3.9.2 and I manage to do it, but it's not permanent; if I switch Node version, npm goes back to 2.15.11 and if I come back to the Node version in which I updated npm, npm is also back to 2.15.11

 $ node -v
0.12.18
 $ npm -v
2.15.1
 $ sudo npm i -g [email protected]
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
[email protected] /usr/local/lib/node_modules/npm
 $ npm -v
3.9.2                  //SUCCESS! right?
 $ sudo n 0.10.48
 $ npm -v
2.15.1                 //nope
 $ sudo n 0.12.18
 $ npm -v
2.15.11                //very nope

What's missing? Could n be the reason my install isn't permanent?

If it's of any relevance I'm using a Mac.


Solution

  • n does a full install of node and npm. The upside is you get the pair that shipped together after you change version using n, the downside is that it may be a downgrade for npm. This is the same outcome as downloading the Mac installer directly from nodejs.org and running.