- How to Update Node.js to Latest Version Home » DevOps and Development » How to Update Node.js to Latest Version Node.js is an open-source JavaScript runtime environment. Since Node.js has an active community of users, minor updates of the software come out every few weeks. You may be using Node.js as a layer of the MEAN stack or in a different JS framework. Either way, make sure to update Node.js regularly to ensure system security. There are several ways to install Node.js and NPM. Likewise, there are several ways to update your Node.js version, depending on the operating system running on your machine. In this article, you will learn how to update to the latest Node.js version on Linux, Windows, and macOS. 3 Ways to Update Node.js to Latest Version on Linux Systems There are different ways to update Node.js if you are using a Linux-based system. Although using the Node Version Manager is the easiest and most recommended option, you can also update with the local package manager or by downloading the binary packages. Option 1: Update Node.js with NVM (Node Version Manager) The best way to upgrade Node.js is with NVM, a practical tool for managing multiple Node.js versions. 1. Start by updating the package repository with the command: 2. Install NVM using the curl command: Note: If you don’t have curl , install the utility by running the command: sudo apt install curl . Alternatively, you use wget and run the command: 3. Close and reopen the terminal for system to recognize the changes or run the command: 5. Then, verify if you have successfully installed NVM: 6. Before upgrading Node.js, check which version you have running on the system: 7. Now you can check for newly available releases with: 8. To install the latest version, use the nvm command with the specific Node.js version: Option 2: Update Node.js with NPM (Node Package Manager) As an alternative, you can use Node’s official package manager to update Node.js. NPM is a tool for installing and managing package dependencies. If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node.js versions and install the latest release. By adding the n module, you can interactively manage Node.js versions. 1. First, clear the npm cache: 2. Install n, Node’s version manager: 3. With the n module installed, you can use it to: Install the latest stable version: Note: Some Ubuntu distros may respond with the command not found output after running the n command. To fix this issue run sudo -E env «PATH=$PATH» [command] . For example, to install the latest stable version, as in the example above, you would run sudo -E env «PATH=$PATH» n stable . Install the latest release: Install a specific version: Option 3: Update Node.js with Binary Packages Updating Node.js with binary packages is the least recommended option. However, if it is the only way you can upgrade to the latest Node.js version, follow the steps outlined below. 1. Navigate to Node’s official downloads page where you can find all available packages. There you can download the source code or pre-built installer for the LTS versions or the latest release. 2. You can either download the package from your browser or find the version number you need and add it to the wget command: 3. Next, install xz-utils used to extract the binary package: 4. Extract and install the package with the command: Update Node.js to Latest Version on Windows and macOS Updating Node.js on Windows and macOS follows the same principles. There are two simple ways to upgrade: Download the latest Node.js release from its official download page and install the new Node.js release. Install the n module and update Node.js inside the terminal window. Option 1: Update Node.js on Windows and macOS with Installer One way to update your Node.js is to go to its official download page and install the newest release. Bz doing so, the system should overwrite the older version with the updated one. 1. Navigate to the Node.js website and click on the latest stable version or the newest current release (with the latest features). 2. After deciding the version, click on the Windows or the macOS Installer, depending on the system you are using. The system downloads the package and stores it in the specified directory. 3. Once the download is complete, run the installer. 4. The Node.js Setup Wizard appears and guides you through the installation. 5. Accept the License Agreement by checking the box and click Next. 6. Choose the destination folder where you want to install Node.js. 7. Node.js allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree. 8. With that, the latest Node.js is ready to install. Click Install to confirm, wait until the installation completes, and click Finish. 9. Check the Node.js version with the command: Note: Sometimes, the system fails to overwrite the older Node.js release and you may end up with two versions. If such problems occur, you may want to consider updating with NPM, outlined in the section below. Option 2: Update Node.js on Windows and macOS with NPM If you want to upgrade Node.js from the command line, use the n model within the npm command. The n feature allows you to interact with different Node.js versions. 1. Before updating the Node.js release, check which version you are currently using with: 2. Next, clear npm cache with the command: 3. Install n globally: 4. Now that you have n installed, you can use the module to install the latest stable release of Node.js: Alternatively, you can install the Node.js release with the latest features: Or, install a specific version number with: The best part of open-source technology is its strong community of users constantly working on upgrading the software. Источник updating nodejs on ubuntu 16.04 I was recently going through the version of node in my ubuntu 16.04 when node -v command was used it shows me version 6.9.1 but when nodejs -v it shows 6.9.2 previously before using this commands npm update command was used. Now what’s these difference in node -v and nodejs -v ? and how to update to the latest LTS version of node/nodejs? 11 Answers 11 To update, you can install n or a specific version node v12 (Old) node v14 (For new users: install this one): node v15 (Current version): Other older versions: Just replace the desired version number in the link above. Optional: install build tools To compile and install native packages To update node to the latest version just: To keep npm updated To find out other versions try npm info npm and in versions find your desired version and replace [version-tag] with that version tag in npm i -g npm@[version-tag] Install it: Test your installation: close your current terminal, open a new terminal, and run: Use it to install as many versions as u like: List installed versions: Use a specific version: Set defaults: Use sudo apt-get install —only-upgrade nodejs to upgrade node (and only upgrade node) using the package manager. The package name is nodejs , see https://stackoverflow.com/a/18130296/4578017 for details. You can also use nvm to install and update node. Then restart the terminal, use nvm ls-remote to get latest version list of node, and use nvm install lts/* to install latest LTS version. nvm is more recommended way to install or update node, even if you are not going to switch versions. Use n module from npm in order to upgrade node To upgrade to latest version (and not current stable) version, you can use sudo apt-get install —reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n Difference: When I first installed node, it installed as ‘nodejs’. When I upgraded it, it created ‘node’. By executing node, we are actually executing nodejs. Node is just a reference to nodejs. From my experience, when I upgraded, it affected both the versions (as it is supposed to). When I do nodejs -v or node -v, I get the new version. Источник How to change to an older version of Node.js I am running Node.js version v0.5.9-pre on Ubuntu 10.10. I would like to be using version v0.5.0-pre . How do I roll back to the older version of node? 17 Answers 17 *NIX (Linux, OS X, . ) Use n, an extremely simple Node version manager that can be installed via npm. Say you want Node.js v0.10.x to build Atom. Windows Use nvm-windows, it’s like nvm but for Windows. Download and run the installer, then: One way is to use NVM, the Node Version Manager. Use following command to get nvm It allows you to easily install and manage multiple versions of node. Here’s a snippet from the help: /.nvm/nvm.sh I always add this line to my /.profile file to have it automatically sources upon login. Often I also put in a line to use a specific version of node.» Update: December 2020 — I have updated the answer because previous one was not relevant. Follow below steps to update your node version. 1. Install nvm For this run below command in your terminal 2. Install specific node version using nvm Replace 12.14.1 with your node version Note: If you are getting error of NVM not recognised then run below command and then run above again 3. Make the installed version default Note: Replace 12.14.1 with your installed version. 4. Check node version And that’s it. Cheers! Why use any extension when you can do this without extension 🙂 Install specific version of node Specific version : sudo n 4.4.4 instead of sudo n stable With package.json — The Maintainable and Portable Way 🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉 Lets each project specify its own version You can add node as a dependency in package.json and control which version is used for a particular project. Upon executing a package.json «script», npm (and yarn ) will use that version to run the script instead of the globally installed Node.js. The node package accomplishes this by downloading a node binary for your local system and puts it into the node_modules/.bin directory. You can also do this with the npm (or yarn ) packages but you’ll need to set your PATH up specifically or use something like npx that handles it for you. Ubuntu — The Official Way (manually) 😵 If you’re on node 12 and want to downgrade to node 10, just remove node and follow the instructions for the desired version: Windows — The Official Way (manually) 😵 I found myself wanting to downgrade to LTS on Windows from the bleeding edge. If you’re not using a package manager like Chocolatey or a node version manager like nvm or n , just download the .msi for the version you want and install it. You might want to remove the currently installed version via «Add or remove programs» tool in Windows. Windows Package Manager — winget 🎉🎉 Chocolatey — The Independent Package Manager Way 🎉 Chocolatey is good for keeping installations up to date easily and it is a common way to install Node.js on Windows. I had to remove the bleeding edge version before installing the LTS version: Node Version Manager — The «Screw it, I’ll do it myself!» Way 😢😢😢😭😭😭😭😭 While not very portable or easily maintainable, some developers like manually switching which global version of node is active at any given point in time and think the official ways of doing this are too slow. There are two popular Npm packages that provide helpful CLI interfaces for selecting (and automatically installing) whichever version you want for your system: nvm and n . Using either is beyond the scope of this answer. I highly recommend staying away from this option. Even though it’s popular, it’s an anti-pattern that is sure to cause headaches in the future. Sure, .nvmrc exists, but this is reinventing something that’s already a part of Npm. Just npm i node the version you want. Источник
- 3 Ways to Update Node.js to Latest Version on Linux Systems
- Option 1: Update Node.js with NVM (Node Version Manager)
- Option 2: Update Node.js with NPM (Node Package Manager)
- Option 3: Update Node.js with Binary Packages
- Update Node.js to Latest Version on Windows and macOS
- Option 1: Update Node.js on Windows and macOS with Installer
- Option 2: Update Node.js on Windows and macOS with NPM
- updating nodejs on ubuntu 16.04
- 11 Answers 11
- How to change to an older version of Node.js
- 17 Answers 17
- *NIX (Linux, OS X, . )
- Windows
- With package.json — The Maintainable and Portable Way 🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉
- Lets each project specify its own version
- Ubuntu — The Official Way (manually) 😵
- Windows — The Official Way (manually) 😵
- Windows Package Manager — winget 🎉🎉
- Chocolatey — The Independent Package Manager Way 🎉
- Node Version Manager — The «Screw it, I’ll do it myself!» Way 😢😢😢😭😭😭😭😭
How to Update Node.js to Latest Version
Home » DevOps and Development » How to Update Node.js to Latest Version
Node.js is an open-source JavaScript runtime environment. Since Node.js has an active community of users, minor updates of the software come out every few weeks.
You may be using Node.js as a layer of the MEAN stack or in a different JS framework. Either way, make sure to update Node.js regularly to ensure system security.
There are several ways to install Node.js and NPM. Likewise, there are several ways to update your Node.js version, depending on the operating system running on your machine.
In this article, you will learn how to update to the latest Node.js version on Linux, Windows, and macOS.
3 Ways to Update Node.js to Latest Version on Linux Systems
There are different ways to update Node.js if you are using a Linux-based system. Although using the Node Version Manager is the easiest and most recommended option, you can also update with the local package manager or by downloading the binary packages.
Option 1: Update Node.js with NVM (Node Version Manager)
The best way to upgrade Node.js is with NVM, a practical tool for managing multiple Node.js versions.
1. Start by updating the package repository with the command:
2. Install NVM using the curl command:
Note: If you don’t have curl , install the utility by running the command: sudo apt install curl .
Alternatively, you use wget and run the command:
3. Close and reopen the terminal for system to recognize the changes or run the command:
5. Then, verify if you have successfully installed NVM:
6. Before upgrading Node.js, check which version you have running on the system:
7. Now you can check for newly available releases with:
8. To install the latest version, use the nvm command with the specific Node.js version:
Option 2: Update Node.js with NPM (Node Package Manager)
As an alternative, you can use Node’s official package manager to update Node.js. NPM is a tool for installing and managing package dependencies.
If you have Node on your system, you have NPM, as well. With the npm command, you can check running Node.js versions and install the latest release.
By adding the n module, you can interactively manage Node.js versions.
1. First, clear the npm cache:
2. Install n, Node’s version manager:
3. With the n module installed, you can use it to:
Install the latest stable version:
Note: Some Ubuntu distros may respond with the command not found output after running the n command. To fix this issue run sudo -E env «PATH=$PATH» [command] . For example, to install the latest stable version, as in the example above, you would run sudo -E env «PATH=$PATH» n stable .
Install the latest release:
Install a specific version:
Option 3: Update Node.js with Binary Packages
Updating Node.js with binary packages is the least recommended option. However, if it is the only way you can upgrade to the latest Node.js version, follow the steps outlined below.
1. Navigate to Node’s official downloads page where you can find all available packages. There you can download the source code or pre-built installer for the LTS versions or the latest release.
2. You can either download the package from your browser or find the version number you need and add it to the wget command:
3. Next, install xz-utils used to extract the binary package:
4. Extract and install the package with the command:
Update Node.js to Latest Version on Windows and macOS
Updating Node.js on Windows and macOS follows the same principles.
There are two simple ways to upgrade:
- Download the latest Node.js release from its official download page and install the new Node.js release.
- Install the n module and update Node.js inside the terminal window.
Option 1: Update Node.js on Windows and macOS with Installer
One way to update your Node.js is to go to its official download page and install the newest release. Bz doing so, the system should overwrite the older version with the updated one.
1. Navigate to the Node.js website and click on the latest stable version or the newest current release (with the latest features).
2. After deciding the version, click on the Windows or the macOS Installer, depending on the system you are using. The system downloads the package and stores it in the specified directory.
3. Once the download is complete, run the installer.
4. The Node.js Setup Wizard appears and guides you through the installation.
5. Accept the License Agreement by checking the box and click Next.
6. Choose the destination folder where you want to install Node.js.
7. Node.js allows you to select how you want to install the Node features. Change the way the features are installed by clicking on the icons in the tree.
8. With that, the latest Node.js is ready to install. Click Install to confirm, wait until the installation completes, and click Finish.
9. Check the Node.js version with the command:
Note: Sometimes, the system fails to overwrite the older Node.js release and you may end up with two versions. If such problems occur, you may want to consider updating with NPM, outlined in the section below.
Option 2: Update Node.js on Windows and macOS with NPM
If you want to upgrade Node.js from the command line, use the n model within the npm command. The n feature allows you to interact with different Node.js versions.
1. Before updating the Node.js release, check which version you are currently using with:
2. Next, clear npm cache with the command:
3. Install n globally:
4. Now that you have n installed, you can use the module to install the latest stable release of Node.js:
Alternatively, you can install the Node.js release with the latest features:
Or, install a specific version number with:
The best part of open-source technology is its strong community of users constantly working on upgrading the software.
Источник
updating nodejs on ubuntu 16.04
I was recently going through the version of node in my ubuntu 16.04 when node -v command was used it shows me version 6.9.1 but when nodejs -v it shows 6.9.2 previously before using this commands npm update command was used.
Now what’s these difference in node -v and nodejs -v ? and how to update to the latest LTS version of node/nodejs?
11 Answers 11
To update, you can install n
or a specific version
node v12 (Old)
node v14 (For new users: install this one):
node v15 (Current version):
Other older versions: Just replace the desired version number in the link above.
Optional: install build tools
To compile and install native packages
To update node to the latest version just:
To keep npm updated
To find out other versions try npm info npm and in versions find your desired version and replace [version-tag] with that version tag in npm i -g npm@[version-tag]
Install it:
Test your installation:
close your current terminal, open a new terminal, and run:
Use it to install as many versions as u like:
List installed versions:
Use a specific version:
Set defaults:
Use sudo apt-get install —only-upgrade nodejs to upgrade node (and only upgrade node) using the package manager.
The package name is nodejs , see https://stackoverflow.com/a/18130296/4578017 for details.
You can also use nvm to install and update node.
Then restart the terminal, use nvm ls-remote to get latest version list of node, and use nvm install lts/* to install latest LTS version.
nvm is more recommended way to install or update node, even if you are not going to switch versions.
Use n module from npm in order to upgrade node
To upgrade to latest version (and not current stable) version, you can use
sudo apt-get install —reinstall nodejs-legacy # fix /usr/bin/node sudo n rm 6.0.0 # replace number with version of Node that was installed sudo npm uninstall -g n
Difference: When I first installed node, it installed as ‘nodejs’. When I upgraded it, it created ‘node’. By executing node, we are actually executing nodejs. Node is just a reference to nodejs. From my experience, when I upgraded, it affected both the versions (as it is supposed to). When I do nodejs -v or node -v, I get the new version.
Источник
How to change to an older version of Node.js
I am running Node.js version v0.5.9-pre on Ubuntu 10.10.
I would like to be using version v0.5.0-pre .
How do I roll back to the older version of node?
17 Answers 17
*NIX (Linux, OS X, . )
Use n, an extremely simple Node version manager that can be installed via npm.
Say you want Node.js v0.10.x to build Atom.
Windows
Use nvm-windows, it’s like nvm but for Windows. Download and run the installer, then:
One way is to use NVM, the Node Version Manager.
Use following command to get nvm
It allows you to easily install and manage multiple versions of node. Here’s a snippet from the help:
/.nvm/nvm.sh I always add this line to my
/.profile file to have it automatically sources upon login. Often I also put in a line to use a specific version of node.»
Update: December 2020 — I have updated the answer because previous one was not relevant.
Follow below steps to update your node version.
1. Install nvm For this run below command in your terminal
2. Install specific node version using nvm
Replace 12.14.1 with your node version
Note: If you are getting error of NVM not recognised then run below command and then run above again
3. Make the installed version default
Note: Replace 12.14.1 with your installed version.
4. Check node version
And that’s it. Cheers!
Why use any extension when you can do this without extension 🙂
Install specific version of node
Specific version : sudo n 4.4.4 instead of sudo n stable
With package.json — The Maintainable and Portable Way 🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉🎉
Lets each project specify its own version
You can add node as a dependency in package.json and control which version is used for a particular project. Upon executing a package.json «script», npm (and yarn ) will use that version to run the script instead of the globally installed Node.js.
The node package accomplishes this by downloading a node binary for your local system and puts it into the node_modules/.bin directory.
You can also do this with the npm (or yarn ) packages but you’ll need to set your PATH up specifically or use something like npx that handles it for you.
Ubuntu — The Official Way (manually) 😵
If you’re on node 12 and want to downgrade to node 10, just remove node and follow the instructions for the desired version:
Windows — The Official Way (manually) 😵
I found myself wanting to downgrade to LTS on Windows from the bleeding edge. If you’re not using a package manager like Chocolatey or a node version manager like nvm or n , just download the .msi for the version you want and install it. You might want to remove the currently installed version via «Add or remove programs» tool in Windows.
Windows Package Manager — winget 🎉🎉
Chocolatey — The Independent Package Manager Way 🎉
Chocolatey is good for keeping installations up to date easily and it is a common way to install Node.js on Windows. I had to remove the bleeding edge version before installing the LTS version:
Node Version Manager — The «Screw it, I’ll do it myself!» Way 😢😢😢😭😭😭😭😭
While not very portable or easily maintainable, some developers like manually switching which global version of node is active at any given point in time and think the official ways of doing this are too slow. There are two popular Npm packages that provide helpful CLI interfaces for selecting (and automatically installing) whichever version you want for your system: nvm and n . Using either is beyond the scope of this answer.
I highly recommend staying away from this option. Even though it’s popular, it’s an anti-pattern that is sure to cause headaches in the future. Sure, .nvmrc exists, but this is reinventing something that’s already a part of Npm. Just npm i node the version you want.
Источник