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/instal
All answers to this questions are useful. Especially the answer given by Travis helped me. For Mac OS X users I would like to provide some steps which will help them to work with the fresh installation of Node Version Manager a.k.a. nvm.
Installing & using nvm on Mac OS X
Here are the steps for fresh installation of nvm and using it without any issue:
Using homebrew install nvm
brew update
brew install nvm
Create .nvm
directory at ~/.nvm
location.
mkdir ~/.nvm
Now if you don't have .bash_profile
file setup for OS X terminal then please create a .bash_profile
at the root level:
nano ~/.bash_profile
Paste below code in the .bash_profile
and press CTRL + O
and press enter to save .bash_profile
file. Press CTRL + X
to exit from editor:
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
Now either quite (CMD + Q
) the terminal or run below command to load .bash_profile
settings:
source ~/.bash_profile
Now run nvm ls
command to get the list of all installed nodejs versions.
If you are using OS X, you might have to create your .bash_profile file before running the installation command. That did it for me.
Create the profile file
touch ~/.bash_profile
Re-run the install and you'll see a relevant line in the output this time.
=> Appending source string to /Users/{username}/.bash_profile
Reload your profile (or close/re-open the Terminal window).
. ~/.bash_profile
First add following lines in ~/.bashrc file
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
then open terminal and source the nvm.sh script
source ~/.nvm/nvm.sh
For the issue was fixed when I moved
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
to the end of .zshrc
source ~/.nvm/nvm.sh
Add this line to ~/.bashrc, ~/.profile, or ~/.zshrc
In macOS, i had to source it using source ~/.nvm/nvm.sh
command to fix this problem.
After that, add these lines
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
onto ~/.bash_profile
so that nvm will be sourced automatically upon login.