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
Works out of the box - thank you !