NVM giving error while doing nvm ls

node.js, nvm

Solution

I recently ran into this problem after I installed nvm as an npm package (from https://npmjs.org/package/nvm).

To resolve the issue, install nvm directly using the instructions at https://github.com/creationix/nvm#installation

Once installed and

source ~/.nvm/nvm.sh

ran (this is important, as it makes nvm available in your current terminal session), then you'll be able to run

nvm ls

and other nvm commands successfully from your project directory.

Hope this helps & cheers to learning node!

Problem

I was trying to install and switch between node version, so i first install nvm using below ``` Administrators-MacBook-Pro:~ user.name$ sudo npm install nvm -g Password: npm http GET https://registry.npmjs.org/nvm npm http 304 https://registry.npmjs.org/nvm npm http GET https://registry.npmjs.org/mkdirp npm http 304 https://registry.npmjs.org/mkdirp /usr/local/bin/nvm -> /usr/local/lib/node_modules/nvm/bin/nvm nvm@0.0.1 /usr/local/lib/node_modules/nvm └── mkdirp@0.3.5 ``` After this i was trying to do "nvm ls" to list node version but it gave me an error(below). Please advice what's wrong with it ``` Administrators-MacBook-Pro:~ user.name$ nvm ls module.js:340 throw err; ^ Error: Cannot find module '/usr/local/lib/node_modules/nvm/bin/nvm-ls' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/usr/local/lib/node_modules/nvm/bin/nvm:15:1) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) ```

Original source