Using node.js 0.4.x with npm 1.0.x via nvm

I ran across this problem and found the following question on stackoverflow:

How can I change the version of npm using nvm?

Here’s my response:

nvm doesn’t handle npm.

So if you want to install node 0.4.x (which many packages still depend on) and use NPM, you can still use npm 1.0.x.

Install node 0.6.x (which comes with npm 1.1.x) and install nvm with npm:

npm install nvm 
. ~/nvm/ 

Install node 0.4.x with nvm:

nvm install v0.4.12 
nvm use v0.4.12 

Install npm using

curl | sh 

This will detect node 0.4.12 and install npm 1.0.106 in your ~/nvm/v0.4.12/lib/node_modules folder and create symlink for nvm

~/nvm/v0.4.12/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js 

If you try to run npm, it will still give an error but if you do nvm use v0.4.12 again, it should now work.