Solution
When installing node I highly recommend, installing it with nvm (Node version manager).
This makes it easy to install a certain version from node with the associated npm.
It also makes switching between node versions very easy.
Install nvm
U can find nvm here: https://github.com/nvm-sh/nvm.
Run:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
This wil create a .nvm directory in your home and tries to update your .bashrc.
See the documentation if you don't use bash almost everything is supported.
Installing node with nvm
Re-open your terminal so that the nvm script is used.
Install your node version:
nvm install 14
Select your node version:
nvm use 14
If you want to check for an specific version run:
nvm ls-remote
Node is installed
Now your version of node is installed with its associated npm version. Every node version has its own node_modules. That means that globally installed npm packages are only for that node version you installed it with.
If you want to switch between node versions just install a new version like nvm install lts
and switch with nvm use lts
.
If you want more information be sure to check out the README.md on their github.