The power of NVM to manage multiple nodejs versions
NVM
NVM describes itself as "Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions"
Installation
For installing NVM run the following command.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
Now it is possible to easily install and switch between different node versions.
nvm install 16
nvm use 16
node -v
Locking the node version for a project
First lets create a new project.
mkdir nvmtest && cd nvmtest
npm init -y
Next we create the .nvmrc file in the root of the project and add the node version into this file.
echo "lts/gallium" > .nvmrc
Now NVM can be used to install the version specified in our project by running the following commands:
nvm use
nvm install