How to Install Node.js for Ubuntu 20.04 LTS?
iroleh.me
iroleh.me
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
Installation nit aside, nodesource is my preferred way to upgrade node on Debian/Ubuntu:
1. It's "just a newer version" of the OS-packaged version! As simple/vanilla as can be.
2. No shell magic making it unclear whether programs running out of the shell will pick up your nvm-managed version of node (most of the time, they won't)
3. And if someday I need to try something on $OLDNODE, it's not much less convenient than nvm: I can just download the deb for $OLDNODE and install it anytime. Then, if you configure your apt cache to keep .debs in /var/cache/apt, switching between versions like nvm does is a matter of just running `sudo dpkg -i /var/cache/apt/node-whatever.deb`. (Sure, it's a bit slower than nvm: a few seconds of install rather than milliseconds of updating a symlink in nvm; still I prefer it for reasons 1. and 2.)
function n() {
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
}
Found it to be a ok workaround for the issue. Otherwise I'm just on nvm just because it continues to work and hasn't gotten in my way, since like 2013 or something. If someone is in the same boat but wanna fix the "slow new shell" thing, this is a quick fix for it.Would love to hear what the "shell config shenanigans" wayneftw talked about, haven't hit that myself.
I came into `nodenv` after being a regular user of `pyenv` for a while. Started with `nvm`, but wished for something more pyenv-like.
There is also `asdf` [2], which seems even more generic. On paper it looks interesting, but I haven't found a solid reason to switch out of `pyenv` and `nodenv`.
Has anyone tried `pyenv` and/or `nodenv` and switched to `asdf`?
[1] https://github.com/pyenv/pyenv [2] https://github.com/asdf-vm/asdf
sudo sh -c 'wget -qO- distro.tools/install/node | sh'