Introduction
Usually we work on different version for our nodejs project and its hard to manage them,but fortunately there is tool called NVM(node verion manager) which help to manage your node version and switch between them according to your projects.
Windows installation
Unfortunately nvm project is only for linux/macos, but...but there is another very similar project by Corey bulter,known as nvm-windows. Click this link download the nvm-setup.zip file and install it in a mundane fashion as on windows.
After installation you can use the same commands as on linux/macos.
Linux installation
In your terminal use curl to install
$ curl -o- https://raw.githubusercontent.com/nvm-sh/v0.34.0/install.sh |
after installation you need to add a bit of configuration in your .bashrc file or .zshrc etc. So, open the file and append the below code.
$ export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm"
[ -s :$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
This sets the path to directory of installation.
Reload your blog terminal, for the changes to take effect and we are good to go.
usage
So let's jump into the terminal and look at some of the commands.
- To Install latest version of node
$ nvm install node
- Install specific version
$ nvm install {node_verion}
#example
$ nvm install 10.0.0
- command to list out all the versions installed
$ nvm ls
- Switching between different node versions
# to use latest version
$ nvm use node
# for a specific verion
$ nvm use 10.0.0
- Deleting node versions
$ nvm uninstall {node_version}
Conclusion
As this was an introductory post, we looked at some of the most used commands, this is a very useful tool if you are working on multiple projects which requires different version of node. You can have a look at the official nvm https://github.com/nvm-sh/nvm gitrepo to understand thoroughly.
Top comments (0)