nodejs updating your npm versions

programming/ javascript/ nodejs

In my earlier posts about installing Node I mentioned the use of NVM (Node Version Manager) and a tool to look after your versions of Node and Npm. NVM itself is regularly updated and therefore you need to make sure what you are using the latest for many different reasons. I always forget how this important component is updated myself so I have decide to put it down here.

If NVM has been installed correctly it should be a git managed folder/repository. You should be able to check this by going to the .nvm folder in your home directory, done via the terminal command:

cd ~/.nvm/

In this directory you should see the usual git management files such as the .git directory and the .gitignore files. If so, you should be able to use git tools to bring down the latest version, if you haven’t got git on your machine then you can follow the guide here to install.

In the .nvm directory you should be able to check for updates by downloading the the latest tagged branches:

git fetch --tags

You can compare the results to the version you are currently running by running:

nvm --version

If you are behind, simply check the version you want by:

git checkout <version>

With including the arrows replaced with the version number eg. git checkout v0.33.5. If you version has changed then simply apply this using the command:

source ~/.nvm/

Happy coding!