I'm pretty new to bash scripting and I'm trying to write a simple script that installs NVM and NODE. This is what I've got:
#!/bin/bash
echo "==> Installing node version manager (NVM)."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
. ~/.nvm/nvm.sh
echo "==> Installing NodeJS"
nvm install node
echo "==> Install complete"
When I run the script it all looks like it works, and I have an .nvm
folder in the directory afterwards, but the commands nvm
and node
don't work, I just get -bash: node: command not found
. I'm assuming this is a linking issue, but I don't know what to add to the script to fix it.
##Edit
It does get added to my .bashrc
like this:
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
Any help appreciated.