Upgrading Node from v4.x.x to v8.x.x

Photo by ALP STUDIO on Unsplash

I personally gets excited and worried both at the same time when nodejs major version gets released. Node community sure do follow a very aggressive release cycles, almost every 6 month there’s a new release of Node.

Unfortunately, I fall in the category of latecomers where I am working on a Node Project which nodejs version 4.x.x. in production but great community of node got us covered there too. Node version manager a.k.a ‘nvm’ worked effortlessly in my case to maintain different version of node.

I use 2 different user( a dev user and a root user), reason being mostly having dev user take care of all local and project related node module dependencies and root user handle all the global dependency. While developing I found this nice article from SO mentioning why it’s not a good idea to use run npm as a root, something worth reading IMO. (https://stackoverflow.com/questions/4938592/how-why-does-npm-recommend-not-running-as-root)

This was the answer for me and worked effortlessly to upgrade Node version. If you have npm installed under root, ensure you uninstall it first before installing nvm. You can directly install nvm under root using -:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh| bash

Make sure to install under root, once installed you can go ahead and install version of node using

nvm install < node-version >

Once you install different version of node using above command, you can use below commands to browse through different version of node and use the desired version as you like.

  • nvm list
  • nvm use <node-version>

Learner, Philomath. Engineer by choice, humorous by nature. Big fan of technology.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store