Skip to content

Instantly share code, notes, and snippets.

@HodoJi
Created February 12, 2025 09:52
Show Gist options
  • Save HodoJi/297a098f07de3e5247826fda4430d346 to your computer and use it in GitHub Desktop.
Save HodoJi/297a098f07de3e5247826fda4430d346 to your computer and use it in GitHub Desktop.
Install NodeJS on Ubuntu 24.04+ and nvm version switching

To install different NodeJS version replace 22 with different version.

# Download and install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# v0.40.1 of nvm was latest version back then, you can replace it with /master/

# instead of restarting the shell
\. "$HOME/.nvm/nvm.sh"

# Download and install Node.js:
nvm install 22

# Verify whether the Node.js is installed:
node -v
nvm current # Check if it is current.

# Verify whether npm is installed:
npm -v

If device has more NodeJS versions installed with nvm, we can switch to version which we want to use.

# to switch to Node 20
nvm use 20

# to switch to Node 22
nvm use 22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment