javascript

Installing Node.js

Unless using Alpine, I prefer to install node.js with nvm to be able to switch versions:

(From here: https://github.com/nvm-sh/nvm )

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# OR
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash


Then install versions, set defaults, etc.

nvm install 14
nvm install 16
# If using a project that e.g. uses node 14:
nvm alias default 14


If using yarn as a package manager instead of npm:

npm install -g yarn
# ^ Global installations go into your current version of node


## Note: With Alpine Linux, I found it not worth it to figure out how to install nvm. I just do this instead:

apk add --update nodejs npm # Currently adds node16