Skip to content

Instantly share code, notes, and snippets.

@MarcoDotIO
Created April 16, 2026 03:33
Show Gist options
  • Select an option

  • Save MarcoDotIO/09cbab122ae0bebd4aba4ad31aa2c1a6 to your computer and use it in GitHub Desktop.

Select an option

Save MarcoDotIO/09cbab122ae0bebd4aba4ad31aa2c1a6 to your computer and use it in GitHub Desktop.
Install NVM with NPM 22 (Latest)
#!/usr/bin/env bash
set -e # Exit on error
echo "=== NVM + Node.js 22 Installation Script ==="
# --- 1. Install prerequisites ---
echo "[1/5] Installing prerequisites..."
sudo apt update
sudo apt install -y curl build-essential
# --- 2. Install NVM ---
echo "[2/5] Installing NVM..."
NVM_VERSION="v0.40.2"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/${NVM_VERSION}/install.sh | bash
# --- 3. Load NVM into current shell ---
echo "[3/5] Loading NVM..."
export NVM_DIR="$HOME/.nvm"
# shellcheck disable=SC1090
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# --- 4. Install Node.js 22 ---
echo "[4/5] Installing Node.js v22..."
nvm install 22
nvm use 22
nvm alias default 22
# --- 5. Verify installation ---
echo "[5/5] Verifying installation..."
node -v
npm -v
nvm --version
echo "=== Installation Complete ==="
echo "Restart your terminal or run: source ~/.bashrc"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment