I am using nvm to manage the node version.
I like to make nvm sourced upon login, so I dont have to do it manually everytime I login.
in my user home directory, there's a .bashrc file. I appended following two lines to the end of the file. then restart my mac os. after I login, nvm is not sourced. I have to manually run them again. coudln't figure out whats wrong. please help.
. ~/nvm/nvm.sh
nvm use 0.8.20
You need to put into your .bash_profile
this line
[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh
Source the file (source ~/.bash_profile
) or reopen the shell and then in the shell execute:
$ nvm alias default <version>
That would load node in any new shell you open.
.nvmrc
fileIt turns out that creating a .nvmrc
file in your home directory is enough. It is loaded automatically when you open the terminal.
To create the .nvmrc
file with the version we want to run (0.12.2) do this:
echo '0.12.2' > ~/.nvmrc
nvm
from your .bashrc
But only if you're running in interactive mode.
Add the command to run nvm use 0.12.2
(or any other version you'd like to run) if the shell is launched in interactive mode to the end of .bashrc
.
echo '[[ $- == *i* ]] && nvm use 0.12.2' >> ~/.bashrc
Boom, done! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With