Skip to content

Instantly share code, notes, and snippets.

@aaronedev
Last active January 5, 2026 11:25
Show Gist options
  • Select an option

  • Save aaronedev/42a1b853a39c89a716041214221e1ba7 to your computer and use it in GitHub Desktop.

Select an option

Save aaronedev/42a1b853a39c89a716041214221e1ba7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
export NVM_DIR="$HOME/.nvm"
if [ ! -s "$NVM_DIR/nvm.sh" ]; then
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
fi
. "$NVM_DIR/nvm.sh"
touch "$HOME/.bashrc" "$HOME/.bash_profile"
grep -q '\. ~/.bashrc' "$HOME/.bash_profile" || printf '\n[ -f ~/.bashrc ] && . ~/.bashrc\n' >>"$HOME/.bash_profile"
grep -q 'export NVM_DIR="$HOME/.nvm"' "$HOME/.bashrc" || cat >>"$HOME/.bashrc" <<'EOF'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
EOF
# repo-driven if .nvmrc exists; otherwise use the same LTS you already have
if [ -f .nvmrc ]; then
nvm install --no-progress
nvm use
else
nvm install lts/krypton --no-progress
nvm use lts/krypton
fi
node -v
npm -v
npm ci
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment