INTRO
As you know node is very popular these days and we can see a lot of currents and new projects around. Having a nice development environment is also crucial to have a better development process alone or in the team.
MY OPINION
For me personally, the best development environment is an isolated environment and why is that? Because it’s not connected to the local system and it’s easily replaceable. One of the tools that I like to use is Docker that helps me to do the job easily, but sometimes I like to run my code from my local environment, and whenever I do that I see trouble with changing NodeJS and NPM version.
SOLUTION
After some research, I find a solution and that is NVM
NVM or Node Version Manager – POSIX-compliant bash script to manage multiple active node.js versions
To install it on Mac/Linux you can run:
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
but if you use the Linux subsystem for Windows it will work too.
After the installation you need to open a new terminal and run:
- nvm install node
and from here you will get the LTS NodeJS/NPM. You’re done here.
SOME USEFUL COMMANDS
For listing the available versions of NodeJS you can run:
- nvm ls-remote
- And for version 16 nvm install v16.3.0
- node -v
For switching the version all you need is for example:
- nvm exec node v14.17.0
- node -v
The path to the executable to where it was installed:
- nvm which 14.17.0
FINAL WORDS
As you can see it’s that easy one NVM to rule them all. Happy coding 🙂