Skip to content

Install Node.js in Linux

asdf is the easiest way to install Node.js in Linux.

1 min read

GitHub for asdf-nodejs. 

Install asdf

Clone and install from the AUR:

Shell command
cd ~/tmp
git clone https://aur.archlinux.org/asdf-vm.git
cd asdf-vm/
makepkg -si

Add some lines to your .profile and .bashrc files:

.profile and .bashrc
echo -e '\nexport PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"' >> ~/.profile
echo -e '\n. <(asdf completion bash)' >> ~/.bashrc

Make changes effective immediately with:

Shell command
source ~/.profile
exec $SHELL

Update asdf

To update to the latest stable version just redo the process above.

Install Node.js

Let's install the latest release of node:

Shell command
asdf plugin add nodejs
# export GNUPGHOME="${ASDF_DIR:-$HOME/.asdf}/keyrings/nodejs" && mkdir -p "$GNUPGHOME" && chmod 0700 "$GNUPGHOME"
# bash ~/.asdf/plugins/nodejs/bin/import-release-team-keyring
asdf list all nodejs
asdf install nodejs 24.0.2
asdf set -u nodejs 24.0.2

Additional package managers

First, let's update npm:

Shell command
npm i -g npm

pnpm

To install pnpm  type:

Shell command
npm install -g pnpm

Test it out:

Shell command
pnpm --version
# x.x.x

Try creating a new Vite project with:

Shell command
pnpm create vite

More posts connected by shared tags.