So, since I started to play with Node.js you basically starts installing NPM, which allows you to install libraries and manage them. So, with some libraries that I test, I usually do:
$ npm update
This command updates your installed libraries, but it doesn't upgrades NPM. To upgrade your installation you require to run this complex command:
$ curl http://npmjs.org/install.sh | sh
It will notice you that your current libraries installed will be lost, and is advised you to backup them, so you can reinstall it. And them, you are done. But, why NPM removes my current installed libraries?
NPM 1.0.x was mainly focused on path/managing your Node.js libraries in a better way, so it requires that your libs be installed with these path changes, which can be local or global paths. In resume, you can now install through:
$ npm install <lib> $ npm install <lib> -g
The latter installs it globally, and usually installed at
development and deployment stuff, you would choose the first, since you will use it as libraries,
and require it at your projects. You will need it globally when it has a CLI (Command Line
Interpreter). When doing so, you get access to it, for example:
$ npm install ender -g $ which ender /usr/local/bin/ender</code>
But, if I wanna both locally and global, do I have to install it twice? The quick answers is, yes.
But NPM can do it more intelligent, so you don't need to upgrade/manage it twice. NPM comes with
link command that allows you to symlink global installs to your local installs. So, every time you
upgrade it globally you get your local also. So, you should be aware of this, since you don't get a
lib@version install, you will get
lib install, so it might broke your code, so use it with this
$ node install express -g $ npm link express $ ls -l ~/node_modules/ $ (...) express -> /usr/local/lib/node_modules/express</code>
Doing this steps you can get back to work when upgrading your NPM installation. For more information read Node.js blog, which has some posts related to NPM.
This is my first post published in english, so there might be some english errors.