Reputation: 7035
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
[email protected] /usr/local/lib/node_modules/nvm
└── [email protected]
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)
Upvotes: 19
Views: 21010
Reputation: 31
my solving nano ~/.zshrc add export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm then restart terminal
Upvotes: 0
Reputation: 771
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!
Upvotes: 52
Reputation: 1091
@jewel is correct: As of January 2016 (and maybe earlier), the NPM-installed version of nvm no longer seems to exist (at least, its github repo gives a 404). If this old, unmaintained package is installed, you may see errors like "local" not implemented yet
or Error: Cannot find module './nvm-help'
when typing nvm commands.
The correct version of nvm now comes from https://github.com/creationix/nvm
If you have installed the earlier (now unmaintained) version, you can get back on the air by doing these steps:
npm uninstall -g nvm
Upvotes: 1
Reputation: 79
To use the nvm command you need to source it as described above. But you don't want to do this after every login.
Just add these lines to your ~/.bashrc, ~/.profile, or ~/.zshrc file to have it automatically sourced upon login:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
See also https://github.com/creationix/nvm#manual-install
Upvotes: 5
Reputation: 109
just to add, I use mac as well but non default shell (zsh) installing nvm will modify .bash_profile (and add line of "source ~/.nvm/nvm.sh")
so I was getting same error, you need to make sure you need to add "source ~/.nvm/nvm.sh" to your shell profile file (for me it was .zshrc)
Upvotes: 2
Reputation: 4449
Did you update your path to include ./node_modules/.bin? E.g.:
export PATH=./node_modules/.bin:$PATH
Upvotes: 0