Skip to content

Instantly share code, notes, and snippets.

@mrbar42
Last active April 30, 2025 01:23
Show Gist options
  • Save mrbar42/faa10a68e32a40c2363aed5e150d68da to your computer and use it in GitHub Desktop.
Save mrbar42/faa10a68e32a40c2363aed5e150d68da to your computer and use it in GitHub Desktop.
Install nodenv on Ubuntu

Installing nodenv on ubuntu

nodenv is a great tool, but its installation on Ubuntu is never smooth for me. Here are instructions to install nodenv along with node-build and node-aliases plugins.

ℹ️ note - nodenv recommands updating the PATH though not all programs run in a shell. i prefer adding symlinks to the nodenv binary and shims to make it available everywhere.

The script can be pasted into a terminal as is

# install the base app
git clone https://github.com/nodenv/nodenv.git ~/.nodenv

# add nodenv to system wide bin dir to allow executing it everywhere
sudo ln -vs ~/.nodenv/bin/nodenv /usr/local/bin/nodenv

# compile dynamic bash extension to speed up nodenv - this can safely fail
cd ~/.nodenv
src/configure && make -C src || true
cd ~/

# install plugins
mkdir -p "$(nodenv root)"/plugins
git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
git clone https://github.com/nodenv/nodenv-aliases.git $(nodenv root)/plugins/nodenv-aliases

# install a node version to bootstrap shims
nodenv install 14.7.0
nodenv global 14

# make shims available system wide
sudo ln -vs $(nodenv root)/shims/* /usr/local/bin/

# make sure everything is working
node --version
npm --version
npx --version
@minhnguyen-vnu
Copy link

Thank you so much <3

@Atlinx
Copy link

Atlinx commented Mar 1, 2025

This works perfectly on Ubuntu 24.04.1!

@SishaarRao
Copy link

You are the 🐐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment