Node Version Manager install - nvm command not found
I am trying to install NVM as per these instructions
I typed in this command in terminal:
$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh
After running the install, I restart the terminal and attempt to install Node.js with this command:
$ nvm install 0.8
but I get the response:
-bash: nvm: command not found
I'm not sure what I am doing wrong here.
Additional Info--
I've been looking around for solutions from other posts and forums. I found another solution using
$ git clone git://github.com/creationix/nvm.git ~/.nvm
but this times out every time I attempt that. Any help would be appreciated. Thanks.
Solution 1:
I think you missed this step:
source ~/.nvm/nvm.sh
You can run this command on the bash OR you can put it in the file /.bashrc or ~/.profile or ~/.zshrc to automatically load it
https://github.com/creationix/nvm
Solution 2:
Check your .bash_profile
, .zshrc
, or .profile
file. You most likely had a problem during the installation.
You should have the following at the end of one of those files.
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh # This loads NVM
The . $HOME/.nvm/nvm.sh
is the same as source $HOME/.nvm/nvm.sh
See: Sourcing a File
You can also check to see if you have a .nvm
folder.
ls -a | grep .nvm
If you're missing that folder then the installation failed to run the git command. This could be due to being behind a proxy. Try running the following instead.
git clone http://github.com/creationix/nvm.git .nvm
Solution 3:
This works for me:
Before installing
nvm
, run this in terminal:touch ~/.bash_profile
After, run this in terminal:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
Important... - DO NOT forget to Restart your terminal OR use command
source ~/.nvm/nvm.sh
(this will refresh the available commands in your system path).In the terminal, use command
nvm --version
and you should see the version
Solution 4:
Quick answer
Figure out the following:
- Which shell is your terminal using, type in:
echo $0
to find out (normally works) - Which start-up file does that shell load when starting up (NOT login shell starting file, the normal shell starting file, there is a difference!)
- Add
source ~/.nvm/nvm.sh
to that file (assuming that file exists at that location, it is the default install location) - Start a new terminal session
- Profit?
Example
As you can see it states zsh
and not bash
.
To fix this I needed to add source ~/.nvm/nvm.sh
to the ~/.zshrc
file as when starting a new terminal my Deepin Terminal zsh reads ~/.zshrc
and not bashs ~/.bashrc
.
Why does this happen
This happens because when installing NVM it adds code to ~/.bashrc
, as my terminal Deepin Terminal uses zsh
and not bash
it never reads ~/.bashrc
and therefor never loads NVM.
In other words: this is NVMs fault.
More on zsh
can be read on one of the answers here.
Quick answer for zsh users
curl raw.github.com/creationix/nvm/master/install.sh | zsh