Open the ~/.bashrc
file and find the following code
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
and replace it with this
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" --no-use # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
if [ -f ".nvmrc" ]; then
nvm use > /dev/null
else
nvm use default > /dev/null
fi
Now go into the project root directory and create a .nvmrc
file and add a node version you want to use like this
v12.22.1
Note: Node version you add in .nvmrc
file must be installed with nvm first, like this nvm install 12.22.1