Installing NVM on macOS and Linux
NVM is the best way I've found to work with Node.js. It keeps Node versions out of the system installation and makes switching between projects painless.
Install NVM with its official script:
sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.7/install.sh | bashRestart your terminal, then install the latest long-term support release:
sh
nvm install --lts
nvm use --ltsConfirm everything works:
sh
node --version
npm --versionFor a project that needs a specific version, add it to an .nvmrc file and run nvm use from that directory. That's the whole setup.