How to update nodejs ubuntu, linux, windows, OSX

Node.js is very popular nowadays. Now its developer’s favorite language for developing Rest APIs and Building high scaling apps. This is the reason node.js project moving very fast and minor updates come every week. There are many modules which are not compatible with old version of node.js.  So today I am going to show you how you can update nodejs ubuntu, linux, windows and OSX.

update nodejs ubuntu

Best and recommended method to update nodejs

Even I am going to  show you all methods to update NodeJS but most recommended way is Node Version Manager.

1. Update Node Using Node Version Manager

Node Version Manager   is best way to  updating Node. When you work with a lot of different NodeJS utilities, you know that sometimes you need to quickly switch to other versions of Node.js . That’s where you can use Node Version Manager to download, install, and use different versions of NodeJS. NVM is a bash script that has the capability to manage multiple active versions of node.js. To install NVM  you’ll need a C++ compiler, as well as the build-essential and libssl-dev packages. So let’s  install NVM first:

Step #1: Install a C++ Compiler

As a matter of best practice we’ll update our packages:

apt-get update

The build-essential package should already be installed, however, we’re going still going to include it in our command for installation:

apt-get install build-essential libssl-dev

Step #2: Install NVM (Node Version Manager)

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

OR Wget:

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh|bash

You’ll have to close and reopen the terminal first, then you can check the version of NVM using this command:

 nvm --version

If you want to check out what versions of Node.js are installed on your machine, you can use the ls option:

nvm ls

/*

v6.5.0

v6.4.0

> v6.3.1

v6.3.0

*/

To install specific version of node.js you can use following command:

nvm install #.#.#

You can tell nvm which version to use in each new shell with nvm use #.#.#.

2. Update Node Using a Package Manager

If you don’t like NVM then you can use Node Package Manager to update nodejs.  Node comes with npm pre-installed, but the manager is updated more frequently than Node. Run npm v to see which version you have, then npm install npm@latest g to install the newest npm update.

update nodejs ubuntu

 

To update Node using Node Package Manager, you’ll need  n module  to update nodejs. Since you probably already have node, the easiest way to install n is through npm:

$ npm install -g n

Use or install the latest official release:

$ n latest

Use or install the stable official release:

$ n stable

Simply execute n <version> to install a version of node. If <version has already been installed (via n), n will activate that version.

$ n 0.8.14
$ n 0.8.17

How to Update Node (Windows/macOS) Using Installers

You can easily update nodejs in windows and macOS this is not that much complex as compare to linux. You can simply go to  nodejs.org download  page and download  pre-made installers — .msi for Windows and .pkg for macOS.  Just download them and run the installer and it will take care rest of things. It will automatically replace old version with new version. The installation process unbelievably efficient and understandable.

Or Alternatively, macOS users can use Node package manager.

Please share if you like the information.

 

Add a Comment

Your email address will not be published. Required fields are marked *