How to update Node on Linux

How to update Node on Linux

To update Node.js on a Linux system, you will need to download the latest version of the Node.js binary package from the official Node.js website and install it on your system.

Here are the general steps you can follow to update Node.js on Linux:

  1. Open a terminal window and navigate to the directory where you want to download the Node.js binary package.

  2. Use the wget command to download the latest version of the Node.js binary package. For example, to download the Linux binary package for version (14.x), you can use the following command:

  1. Extract the downloaded package using the tar command. For example, if the package is named node-v14.x-linux-x64.tar.gz, you can extract it using the following command:

tar xzf node-v14.x-linux-x64.tar.gz
  1. This will create a directory with the extracted files. To install the updated version of Node.js, you will need to copy the files from this directory to the appropriate locations on your system. You can do this using the cp command. For example, to copy the files to the /usr/local directory, you can use the following commands:

cd node-v14.x-linux-x64
sudo cp -r bin include lib share /usr/local/
  1. Once the files are copied, you can verify that the update was successful by running the node -v command, which will print the version number of the installed Node.js. You should see the updated version number in the output.

Remember that these are general steps, and the exact commands you need to use may vary depending on your specific system and the version of Node.js you are updating.

Important notes

There are a few other things you should keep in mind when updating Node.js on Linux.

First, make sure you have the necessary permissions to perform the update. Depending on how Node.js was originally installed on your system, you may need to use the sudo command to run the cp command with the necessary privileges.

Second, keep in mind that updating Node.js will not automatically update the npm package manager, which is used to install and manage Node.js packages. If you want to update npm as well, you can use the following command:

sudo npm install -g npm

Third, if you have any global npm packages installed, you may need to reinstall them after updating Node.js. You can do this by running the following command:

npm -g ls --depth=0

This will print a list of the global npm packages installed on your system. You can then reinstall each package using the npm install -g command, followed by the package name. For example, to reinstall the request package, you would use the following command:

npm install -g request

Finally, keep in mind that updating Node.js may cause compatibility issues with your existing applications. If you have any Node.js applications running on your system, you should test them after updating to ensure they continue to work as expected.

Stay up to date

Get notified when I publish New Games or articles, and unsubscribe at any time.

Thanks for joining!

Related articles

Ruslan Osipov
Author: Ruslan Osipov