lobo_tuerto's notes
for greatly improving DX
Blog
Notes
About

Install Node.js in Linux

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

📅Date10 March 2018Updated28 August 2021
🏷️
devlinuxnodejs

Link to the project asdf-nodejs.

Install asdf

Clone the GitHub repository:

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.8.1

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

echo -e '\n. $HOME/.asdf/asdf.sh' >> ~/.profile
echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.bashrc

Make changes effective with:

source ~/.profile
exec $SHELL

If we add asdf.sh to ~/.profile instead of ~/.bashrc, it will have the side effect of allowing applications started through dmenu —for i3 users— to be able to call ASDF installed commands.

This is because stuff in ~/.profile gets loaded when you login into your account, so anything there will be available to other programs run through dmenu or desktop icons.

On the other hand, stuff in ~/.bashrc gets loaded everytime you open a terminal. So another way to have VSCode work with ASDF stuff would be to just start code from the CLI.

Update asdf

To update to the latest stable version just type:

asdf update

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 16.8.0
asdf global nodejs 16.8.0

Add Yarn globally:

npm install -g yarn

# After installing a global package that contains executables run:
asdf reshim nodejs

Test it out:

yarn --version
# x.x.x

Try creating a new Vite project with:

yarn create vite

Got comments or feedback?
Follow me on
rev-7175614