Skip to content

Instantly share code, notes, and snippets.

@defaye
Created May 26, 2020 12:41
Show Gist options
  • Save defaye/58921f409536948b6b7fa1e3ea777303 to your computer and use it in GitHub Desktop.
Save defaye/58921f409536948b6b7fa1e3ea777303 to your computer and use it in GitHub Desktop.
Install Node.js via NVM automatically using the latest LTS
# https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-18-04
curl -sL https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh -o install_nvm.sh
bash install_nvm.sh
{ cat << 'EOT'; cat << EOF; } >> ~/.$(echo $SHELL | grep -o '[^/]*$')rc
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
EOT
EOF
source ~/.$(echo $SHELL | grep -o '[^/]*$')rc
nvm install $(nvm ls-remote | grep "Latest LTS" | tail -1 | grep -oP '(\d+\.?){3}')
@defaye
Copy link
Author

defaye commented Jun 2, 2020

To run this command in one line:

curl -s https://gist.githubusercontent.com/defaye/58921f409536948b6b7fa1e3ea777303/raw/c6a8e11b955ace9b9433ec165e64462ede673800/install_nvm_node.sh | sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment