Last active
July 4, 2025 22:19
-
-
Save alexolinux/117211194783a1a11a38e6aee2d4bafb to your computer and use it in GitHub Desktop.
Script to install Node Version Manager (NVM).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#https://github.com/nvm-sh/nvm/releases | |
NVM_VER="v0.40.3" | |
# Check if NVM is already installed | |
if [ -z "$(command -v nvm)" ] && [ -z "$NVM_DIR" ]; then | |
echo "---- NVM Installation ----" | |
# Check if curl is installed | |
if [ ! -z "$(command -v curl)" ]; then | |
echo "Downloading nvm..." | |
curl -o- "https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VER}/install.sh" | bash | |
# Check if download and installation succeeded | |
if [ "$?" -eq 0 ]; then | |
echo "NVM installed successfully!" | |
echo "Restart your SHELL Session." | |
else | |
echo "Error installing NVM." | |
exit 1 | |
fi | |
else | |
echo "CURL Command not found. Install curl before proceeding with this script." | |
exit 1 | |
fi | |
else | |
echo "NVM is already installed. Sourcing NVM initialization script..." | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
nvm --version | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NVM Useful commands
nvm alias default v20.12.2