How do I upgrade my node.js

Linode Staff

Current nodeJs version in my server is v8.10.0. My developer had installed it. I want to upgrade it to version 10.16 . Whats the process to update it.

1 Reply

Linode Staff

There are a number of ways to upgrade Node.js, but perhaps the most straightforward way is to use Node.js's native command-line utilities to perform the upgrade.

Determine which version of Node.js is currently installed

In case you aren't sure which version of Node.js you are running, you can run the node --version command to determine it:

$ node --version
v8.10.0

Update Node.js using its own command-line utilities

Node.js uses a package manager called NPM, which can install Node.js as well as update your Node.js version for you.

Before getting started, it is best to make sure that your system has NPM installed. Every Linux distribution itself has its own package manager, so be sure to consult your distribution's package manager for the proper syntax that will install a package.

For example, Debian/Ubuntu use the apt package manager, so you will run this command from these distributions to install NPM:

$ sudo apt install npm

The package is almost certainly called npm in your Linux distribution's package manager's repositories, but most if not all Linux distribution package managers allow you to search the repositories for a specific package or command.

Once you get NPM installed, it is important to make sure you are using the latest version of NPM. You can see which version of NPM you have installed with this command:

$ npm --version
3.5.2

You can upgrade to the latest version of NPM with this command:

$ sudo npm install -g npm@latest

Confirm that the new version of NPM is installed:

$ npm --version
6.13.0

You may need to log out and log back in to confirm this update.

Once NPM is updated, install the n package for managing your Node.js versions:

$ sudo npm install -g n@latest

Once you have the n package installed, run it along with the version to which you would like to upgrade your Node.js:

$ sudo n 10.16

You can also upgrade to the latest version of Node.js using this command:

$ sudo n latest

After the command completes, verify that your Node.js installation reports the correct version:

$ node --version
v10.16.3

As with upgrading NPM, you may need to log out and log back in to see the version change. You may also need to restart any services which use Node.js in order for them to use the new version.

I hope these instructions allow you to smoothly upgrade your Node.js installation for use by your Linode's applications. If you have any trouble with these instructions on your system or find them unclear, please feel free to post a follow-up to this thread.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct