2018 / 03 / 10
2023 / 12 / 12
Install Node.js in Linux

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

linux
dev
nodejs

GitHub for asdf-nodejs.

Install asdf

Clone and install from the AUR:

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:

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

Make changes effective immediately with:

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:

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:

npm i -g npm

pnpm

To install pnpm type:

npm install -g pnpm

Test it out:

pnpm --version
# x.x.x

Try creating a new Vite project with:

pnpm create vite

Links