nvm icon indicating copy to clipboard operation
nvm copied to clipboard

-bash: nvm: command not found

Open apaternite opened this issue 12 years ago • 195 comments

Running terminal in Mac OS X Yosemite.

Followed the installation instructions and restarted terminal: curl https://raw.githubusercontent.com/creationix/nvm/v0.18.0/install.sh | bash

When using nvm I always get -bash: nvm: command not found

When installing again: => nvm is already installed in /Users/Tony/.nvm, trying to update => HEAD is now at 5f5eb47... v0.18.0

I do have npm already installed. Does that matter?

apaternite avatar Nov 12 '14 18:11 apaternite

Having node and npm already installed doesn't matter.

However, you do need to nvm use before nvm will take over your PATH and let you use nvm's version of node.

Can you check your ~/.bash_profile and ~/.bashrc for the relevant nvm lines, and paste them here? Also, what does echo $PATH say on a new shell?

ljharb avatar Nov 13 '14 16:11 ljharb

Please reopen if you discover this is actually a problem with nvm.

ljharb avatar Nov 22 '14 18:11 ljharb

I had the same issue until I added the following lines to my .bash_profile

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

alfredbez avatar Dec 04 '14 12:12 alfredbez

Hmm, install.sh should add those to .bashrc or .bash_profile for you, which if you'd manually created it, should be sourced inside bash_profile. Perhaps that's the issue, that bashrc exists but isn't sourced inside bash_profile?

ljharb avatar Dec 04 '14 18:12 ljharb

I was having the same issue. After installing nvm, I had to exit from bash and re-login to make it work (I read it somewhere earlier). I think we should update the README.

Tried on CentOS 7 in VM (dev installation mode, CLI only).

am11 avatar Jan 16 '15 23:01 am11

Hi,

I've got the same problem on Mac OS X 10.10 Yosemite. I've installed nvm with the command : curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

This add the following lines in my .bashrc file: export NVM_DIR="/Users/jeancreuzedeschatelliers/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

And I also add the following line at the bottom of the same file: source ~/.nvm/nvm.sh

But it doesn't work. I must execute this last command every time I want use nvm.

Any idea ?

jeancdc avatar Apr 04 '15 21:04 jeancdc

@jeancdc . something and source something are the same, except that the . is more portable, so you should definitely remove that redundant source line.

However, unless you run something like nvm alias default stable, every shell is intended to start with nvm in a deactivated but available state. Perhaps that's the issue?

ljharb avatar Apr 04 '15 21:04 ljharb

  • I've removed the source ~/.nvm/nvm.sh line,
  • install a version of node with nvm install 0.12.2
  • use this default version of node with nvm alias default 0.12.2

But still the same problem when I quit the terminal and restart it... I must execute source ~/.nvm/nvm.sh every time I launch the terminal...

jeancdc avatar Apr 04 '15 22:04 jeancdc

export NVM_DIR="/Users/jeancreuzedeschatelliers/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm - this should be two lines, like so:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

ljharb avatar Apr 04 '15 22:04 ljharb

@jeancdc does that fix your issue?

ljharb avatar Apr 04 '15 23:04 ljharb

It was already two lines. Maybe I made wrong when I copied-paste this. But still the same problem... :-(

jeancdc avatar Apr 05 '15 15:04 jeancdc

OK, I've done the same thing than @alfredbez and it works:

Like he said, I must to add the following lines at the end of the ~/.bash_profile file:

export NVM_DIR=~/.nvm
source ~/.nvm/nvm.sh

Maybe the author @creationix should add these instructions in the README.markdown file.

Thanks to you !

jeancdc avatar Apr 05 '15 15:04 jeancdc

@jeancdc Usually the install script does it for you, so nothing is needed in the readme. what OS are you using?

ljharb avatar Apr 05 '15 18:04 ljharb

I use Mac OS X 10.10.2 Yosemite

jeancdc avatar Apr 05 '15 19:04 jeancdc

@jeancdc I'm not sure how you installed nvm, but the install script should have done that for you. How did you install it?

ljharb avatar Apr 05 '15 19:04 ljharb

with this command: curl https://raw.githubusercontent.com/creationix/nvm/v0.24.0/install.sh | bash

jeancdc avatar Apr 05 '15 19:04 jeancdc

yup, that should do it. On a hunch - do you use any other shells? What does ls -a ~ | \grep -e '^\.' output? (ie, what other dotfiles do you have)

It's possible that it's already in your .bashrc file, and the problem is just that your .bash_profile doesn't source .bashrc anywhere in it.

ljharb avatar Apr 05 '15 19:04 ljharb

I use the default terminal.

This is the result of the command:

.
..
.CFUserTextEncoding
.DS_Store
.MacOSX
.MakeMKV
.OpenCobolIDE
.Scilab
.Trash
.WebStorm9
.Xauthority
.adobe
.android
.avidemux
.bash_history
.bash_profile
.bash_profile.macports-saved_2012-01-22_at_20:47:07
.bash_profile.macports-saved_2014-06-03_at_21:50:12
.bash_profile.macports-saved_2014-10-18_at_22:28:07
.bash_profile.pysave
.bash_profile.swo
.bashrc
.bundle
.cache
.codeintel
.composer
.config
.cordova
.cups
.dbus-keyrings
.dtLiteMacLicense.dat
.dvdcss
.eclipse
.eclipse_keyring
.f-secure
.filezilla
.fontconfig
.gem
.gitconfig
.gitignore_global
.gnome2
.goodsync
.gradle
.heroku
.hgignore_global
.idlerc
.inkscape-etc
.lincity-ng
.local
.m2
.macports
.matlab
.mkshrc
.mplayer
.mypaint
.nchsoftware
.netrc
.nexuiz
.node-gyp
.npm
.nvm
.pdfsam
.pgpass
.pia_manager
.pia_manager_crash.log
.plugman
.profile
.psql_history
.rnd
.rvm
.serverauth.81878
.serverauth.981
.sqlite_history
.ssh
.subversion
.swt
.thumbnails
.viminfo
.widelands
.windows-serial
.wine
.xinitrc.d
.zlogin
.zshrc

jeancdc avatar Apr 05 '15 19:04 jeancdc

If you check .bashrc and .zshrc and .profile, do any of them contain the nvm sourcing lines?

If so, then it's that the install script's shell detection is a bit wonky.

ljharb avatar Apr 05 '15 19:04 ljharb

Here is what there are in the ~/.bashrc file:

export NVM_DIR=« $HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

Nothing in the ~/.zshrc and in the ~/.profile files related to NVM.

jeancdc avatar Apr 05 '15 19:04 jeancdc