How to install node version
How to install node version
Search Results
No Results
Filters
Installing and Using NVM (Node Version Manager)
The Node Version Manager (NVM) is an open source version manager for Node.js (Node). NVM is easy to understand and works on any POSIX-compliant shell (for example, sh or bash). NVM allows you to easily install and manage different versions of Node and switch between them on a per-shell basis. This guide describes how to install NVM, and how to use it to install and run different versions of Node.
Advantages of NVM
Node changes quickly and testing applications with different versions is often difficult. Since NVM enables quick and effortless switching between Node versions, it is much easier to test version compatibility and upgrades with multiple libraries. NVM stores the Node versions and associated modules inside your user directory, so sudo does not have to be used. NVM also simplifies the installation and compilation process because Node versions no longer have to be obtained directly from the distribution channel.
A Summary of the NVM Installation and Configuration Process
A complete NVM installation consists of the following high-level steps. Each step is described below.
Install NVM
As an alternate method, you can execute the new instructions in the same console to apply them immediately.
NVM uses the following environmental variables. We recommend leaving them at the default settings. Use caution if you decide to change them for any reason.
Confirm you have successfully installed NVM.
You can confirm the version of NVM that is running with the following command:
Use NVM to Install Node
NVM’s install command downloads, compiles, and installs the specified version of Node. You can install as many versions of Node as you want.
To install the latest version of Node, run the following:
After a successful install, NVM displays information about the installation.
To install a specific version of Node, specify the major or minor release number. You can preview a list of all available Node versions with the ls-remote command.
NVM displays a long list of available versions in the following format:
Install any additional versions of Node you want to use. You can specify either a major or minor release of Node to install. When you install a new version of Node, NVM immediately begins using it and designates it as the current version.
List Node Versions with NVM
Review all installed versions of Node with the ls command.
NVM returns a list of all Node versions and aliases, along with an arrow indicating the current version. Here is a sample output:
The NVM Use Command
NVM confirms it is now using the new version.
NVM again returns the current version number.
NVM: Switch Node Version
NVM confirms it is now running the selected version of Node and returns a Node prompt.
Creating NVM Aliases
Use the nvm alias command to change the default Node version. Follow the alias keyword with the default alias and the new version of Node it should reference.
NVM confirms the new value for the alias.
Use the nvm alias command to create a new alias. The following example defines a new maintenance alias as Node version 13.10.1.
NVM confirms the new alias.
You can display all of the new and old aliases with the nvm ls command.
Use NVM to Install Latest LTS Node.js Release
Any Node.js version can be in one of the following three release phases: “Current”, “Active Long Term Support (LTS)”, and “Maintenance”. The LTS release version of Node.js includes new features, bug fixes, and updates that have been approved to be a part of the release line. This section shows you how to install the latest LTS version of Node.js using NVM.
Use the following command to install the latest LTS version of Node.js on your system:
You should see the following output:
After the installation is complete NVM automatically switches to the latest LTS version of Node.js that you just installed.
The example command installs the “argon” LTS line of Node.js. Refer to the Node.js Releases page for LTS release names.
To switch to the latest LTS version of Node.js that is already installed on your system, use the following command:
To switch to a specific LTS version of Node.js, use the following command:
The example command switches to the “argon” LTS line of Node.js.
Additional NVM Capabilities
Although NVM is very straightforward to use, it also provides some advanced capabilities. See the NVM GitHub page for a full list of all advanced topics.
Use NVM to Uninstall Node
NVM allows you to uninstall Node versions that are no longer required.
Run the command nvm uninstall with the version of Node you’d like to remove. You cannot remove a version you are currently using, so you must switch to a different version first.
NVM confirms the Node version has been removed.
NVM Uninstall Steps
If you no longer intend to use NVM, you can uninstall it with the unload command.
Deactivate NVM with the nvm deactivate command. This clears any path variables.
More Information
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This page was originally published on Tuesday, January 12, 2021.
How to install latest node version on Ubuntu?
I want to install the latest node (v6.2.0 at the time of writing) on Ubuntu. But as I do
This installed v0.10.37.
Can you please help me in installing the latest version of node js and also npm latest version?
12 Answers 12
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
This is very simple, Grab the Linux node distribution from here: https://nodejs.org/dist/v6.2.0/
Open Terminal and type below command:
Now check your node version by typing:
One can install any version of node in Ubuntu using above steps.
Follow https://deb.nodesource.com/setup_6.x to read shell script before execute above commands.
You always must to know what you run, especially by sudo.
Any version of node install is very easy
Just click Node.js scroll down and go Installation instructions and chose which version you want to install
To Install 12.x version of node:
Using Ubuntu
Using Debian, as root
To remove previous version use command
and then for latest version
Or for stable version
By far the most convenient way to install and manage node versions on your machine is the Node Version Manager a.k.a nvm. Just follow the installation instructions in the repo and after you have it installed run
RECOMMENDED READING
EDIT
If you wish to completely reinstall nodejs, check out the script located here:
and check out this:
It says Mac OSX, but it’ll work perfectly fine in ubuntu, too.
depends on what version of latest nodejs you want to install if LTS version or current latest version, then from PPA
latest LTS version
current latest version
I would suggest installing through package manager to make sure it installs with accurate dependencies.
to install modules, like so:
Install the snap package
The easiest method to install Node.js on Ubuntu is to use the snap package. Just search for node on Ubuntu Software store and install the first one.
Or if you prefer command line:
Alternate method: NVM
If you can’t use snaps for some reason, like from a WSL environment, then Node Version Manager (NVM) is the way to go. It’s safer than upgrading the node packages in Ubuntu to unsupported versions from PPAs or 3rd party repos, which may cause conflicts or breakages in apt package management system. Compared to NVM, manual installations from tarballs are harder to maintain and upgrade. Follow these steps to install the latest node using NVM:
Step 1: Install NVM
Run this command in Terminal:
Step 2: Install node
Once NVM installation is complete, close and reopen Terminal. Then run this command:
Step 3: Check node version
Run these commands:
If everything went well, you’ll see the latest node and npm versions as output. That’s all, node is installed and ready to run! 😊
nvm-sh/nvm
Use Git or checkout with SVN using the web URL.
Work fast with our official CLI. Learn more.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Node Version Manager
Table of Contents
nvm allows you to quickly install and use different versions of node via the command line.
Example:
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
Installing and Updating
Install & Update Script
To install or update nvm, you should run the install script. To do that, you may either download and run the script manually, or use the following cURL or Wget command:
Running either of the above commands downloads a script and runs it. The script clones the nvm repository to
Troubleshooting on Linux
These should pick up the nvm command.
Troubleshooting on macOS
Since OS X 10.9, /usr/bin/git has been preset by Xcode command line tools, which means we can’t properly detect if Git is installed or not. You need to manually install the Xcode command line tools before running the install script, otherwise, it’ll fail. (see #1782)
If you get nvm: command not found after running the install script, one of the following might be the reason:
/.zshrc and run the install script again.
/.bash_profile and run the install script again. Then, run source
/.bash_profile to pick up the nvm command.
If the above didn’t help, you might need to restart your terminal instance. Try opening a new tab/window in your terminal and retry.
If the above doesn’t fix the problem, you may try the following:
/.profile ) does not source your
/.bashrc properly. You could fix this by adding source
/ to it or follow the next step below.
Try adding the snippet from the install section, that finds the correct nvm directory and loads nvm, to your usual profile (
For more information about this issue and possible workarounds, please refer here
You can use a task:
To verify that nvm has been installed, do:
which should output nvm if the installation was successful. Please note that which nvm will not work, since nvm is a sourced shell function, not an executable binary.
If you’re running a system without prepackaged binary available, which means you’re going to install nodejs or io.js from its source code, you need to make sure your system has a C++ compiler. For OS X, Xcode will work, for Debian/Ubuntu based GNU/Linux, the build-essential and libssl-dev packages work.
Note: nvm also support Windows in some cases. It should work through WSL (Windows Subsystem for Linux) depending on the version of WSL. It should also work with GitBash (MSYS) or Cygwin. Otherwise, for Windows, a few alternatives exist, which are neither supported nor developed by us:
Note: nvm does not support Fish either (see #303). Alternatives exist, which are neither supported nor developed by us:
Note: We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need patches; see the issue ticket:
Note: On OS X, if you do not have Xcode installed and you do not wish to download the
Note: On OS X, if you have/had a «system» node installed and want to install modules globally, keep in mind that:
Note: If you’re using zsh you can easily install nvm as a zsh plugin. Install zsh-nvm and run nvm upgrade to upgrade.
Note: Git versions before v1.7 may face a problem of cloning nvm source from GitHub via https protocol, and there is also different behavior of git before v1.6, and git prior to v1.17.10 can not clone tags, so the minimum required git version is v1.7.10. If you are interested in the problem we mentioned here, please refer to GitHub’s HTTPS cloning errors article.
If you have git installed (requires git v1.7.10+):
Now add these lines to your
/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
Now add these lines to your
/.zshrc file to have it automatically sourced upon login: (you may have to add to more than one of the above files)
For manual upgrade with git (requires git v1.7.10+):
To download, compile, and install the latest release of node, do this:
To install a specific version of node:
The first version installed becomes the default. New shells will start with the default version of node (e.g., nvm alias default ).
You can list available versions using ls-remote :
And then in any new shell just use the installed version:
Or you can just run it:
Or, you can run any arbitrary command in a subshell with the desired version of node:
You can also get the path to the executable to where it was installed:
To get the latest LTS version of node and migrate your existing installed packages, use
Migrating Global Packages While Installing
If you want to install a new version of Node.js and migrate npm packages from a previous version:
This will first use «nvm version node» to identify the current version you’re migrating packages from. Then it resolves the new version to install from the remote server and installs it. Lastly, it runs «nvm reinstall-packages» to reinstall the npm packages from your prior version of Node to the new one.
You can also install and migrate npm packages from specific versions of Node like this:
Note that reinstalling packages explicitly does not update the npm version — this is to ensure that npm isn’t accidentally upgraded to a broken version for the new node version.
or, you can at any time run the following command to get the latest supported npm version on the current node version:
Default Global Packages From File While Installing
If you want to install io.js:
If you want to install a new version of io.js and migrate npm packages from a previous version:
The same guidelines mentioned for migrating npm packages in node are applicable to io.js.
System Version of Node
If you want to use the system-installed version of node, you can use the special default alias «system»:
If you want to see what versions are installed:
If you want to see what versions are available to install:
Setting Custom Colors
You can set five colors that will be used to display version and alias information. These colors replace the default colors. Initial colors are: g b y r e
Persisting custom colors
If you want the custom colors to persist after terminating the shell, export the NVM_COLORS variable in your shell profile. For example, if you want to use cyan, magenta, green, bold red and bold yellow, add the following line:
Suppressing colorized output
To restore your PATH, you can deactivate it:
Set default node version
To set a default Node version to be used in any new shell, use the alias ‘default’:
Use a mirror of node binaries
For example, to make nvm default to the latest 5.9 release, the latest LTS version, or the latest node version for the current directory:
Then when you run nvm:
Deeper Shell Integration
You can use avn to deeply integrate into your shell and automatically invoke nvm when changing directories. avn is not supported by the nvm maintainers. Please report issues to the avn team.
If you prefer a lighter-weight solution, the recipes below have been contributed by nvm users. They are not supported by the nvm maintainers. We are, however, accepting pull requests for more examples.
Automatically call nvm use
This requires that you have bass installed.
Tests are written in Urchin. Install Urchin (and other dependencies) like so:
There are slow tests and fast tests. The slow tests do things like install node and check that the right versions are used. The fast tests fake this to test things like aliases and uninstalling. From the root of the nvm git repository, run the fast tests like this:
Run the slow tests like this:
Run all of the tests like this:
Nota bene: Avoid running nvm while the tests are running.
nvm exposes the following environment variables:
To activate, you need to source bash_completion :
How To Install Node.js on Ubuntu 16.04
Introduction
Node.js is a JavaScript runtime for server-side programming. It allows developers to create scalable backend functionality using JavaScript, a language many are already familiar with from browser-based web development.
In this guide, we will show you three different ways of getting Node.js installed on an Ubuntu 16.04 server:
For many users, using apt with the default repo will be sufficient. If you need specific newer (or legacy) versions of Node, you should use the PPA repository. If you are actively developing Node applications and need to switch between node versions frequently, choose the nvm method.
Prerequisites
This guide assumes that you are using Ubuntu 16.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following the Ubuntu 16.04 initial server setup tutorial.
Option 1 — Installing Node.js with Apt from the Default Repositories
Warning: the version of Node.js included with Ubuntu 16.04, version 4.2.6 is now unsupported and unmaintained. You should not use this version, and should refer to one of the other sections in this tutorial to install a more recent version of Node.
To get this version, you can use the apt-get package manager. Refresh your local package index first by typing:
Then install Node.js:
Check that the install was successful by querying node for its version number:
This will allow you to install modules and packages to use with Node.js.
At this point you have successfully installed Node.js and npm using apt-get and the default Ubuntu software repositories. The next section will show how to use an alternate repository to install different versions of Node.js.
Option 2 — Installing Node.js with Apt Using a NodeSource PPA
To install a different version of Node.js, you can use a PPA (personal package archive) maintained by NodeSource. These PPAs have more versions of Node.js available than the official Ubuntu repositories. Node.js v12, v14, and v16 are available as of the time of writing.
First, we will install the PPA in order to get access to its packages. From your home directory, use curl to retrieve the installation script for your preferred version, making sure to replace 16.x with your preferred version string (if different).
Refer to the NodeSource documentation for more information on the available versions.
Inspect the contents of the downloaded script with nano (or your preferred text editor):
When you are satisfied that the script is safe to run, exit your editor, then run the script with sudo :
The PPA will be added to your configuration and your local package cache will be updated automatically. You can now install the Node.js package in the same way you did in the previous section:
At this point you have successfully installed Node.js and npm using apt and the NodeSource PPA. The next section will show how to use the Node Version Manager to install and manage multiple versions of Node.js.
Option 3 — Installing Node Using the Node Version Manager
Another way of installing Node.js that is particularly flexible is to use nvm, the Node Version Manager. This piece of software allows you to install and maintain many different independent versions of Node.js, and their associated Node packages, at the same time.
To install NVM on your Ubuntu 16.04 machine, visit the project’s GitHub page. Copy the curl command from the README file that displays on the main page. This will get you the most recent version of the installation script.
Take a look and make sure you are comfortable with the changes it is making. When you are satisfied, run the command again with | bash appended at the end. The URL you use will change depending on the latest version of nvm, but as of right now, the script can be downloaded and executed by typing:
Now, you can ask NVM which versions of Node are available:
It’s a very long list! You can install a version of Node by typing any of the release versions you see. For instance, to get version v14.10.1, you can type:
You can see the different versions you have installed by typing:
Additionally, you’ll see aliases for the various long-term support (or LTS) releases of Node:
You can switch between installed versions with nvm use :
The correct version of Node is installed on our machine as we expected. A compatible version of npm is also available.
Conclusion
There are a quite a few ways to get up and running with Node.js on your Ubuntu 16.04 server. Your circumstances will dictate which of the above methods is best for your needs. While using the packaged version in Ubuntu’s repository is the easiest method, using nvm or a NodeSource PPA offers additional flexibility.
For more information on programming with Node.js, please refer to our tutorial series How To Code in Node.js.
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in our Questions & Answers section, find tutorials and tools that will help you grow as a developer and scale your project or business, and subscribe to topics of interest.
How to install a specific version of Node on Ubuntu?
17 Answers 17
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
The n module worked for me.
Run this code to clear npm’s cache, install n, and install the latest stable version of Node:
To install a specific version of node:
To check what version:
You might need to restart
Chris Lea has 0.8.23 in his ppa repo.
This package let you add a repository to apt-get: (You can also do this manually)
Add Chris Lea’s repository:
I think (feel free to edit) the version number is optional if you only add node.js-legacy. If you add both legacy and ppa/chris-lea/node.js you most likely need to add the version.
For example, currently recent 4.x version is 4.2.4, but you can install previous 4.2.3 version.
NVM (Node Version manager)
allows you to use multiple versions of Node and without sudo
is analogous to Ruby RVM and Python Virtualenv, widely considered best practice in Ruby and Python communities
downloads a pre-compiled binary where possible, and if not it downloads the source and compiles one for you
Tested in Ubuntu 17.10:
For the particular case of the most recent long term support version (recommended if you can choose):
With this setup, you get for example:
and if we want to use the globally installed module:
as mentioned at:
For projects however, you are better off just using packages installed locally under node_modules and npx for executable to be able to have independent versions across projects, global usage is mostly for the Node executable itself and global CLI utilities not specific to any project.
so we see that everything is completely contained inside the specific node version.
Setting the NPM version
The executable is placed inside the current NVM version, so everything remains nice and isolated, e.g.:
gives something like:
Try this way. This worked me.
wget nodejs.org/dist/v0.10.36/node-v0.10.36-linux-x64.tar.gz(download file)
Say you want to install Node 10,
Firstly, download and execute the Node.js 10.x installer:
This will add a source file for the official Node.js 10.x repo, grabs the signing key
Once the installer is done doing it’s thing, you will need to install (or upgrade) Node.js:
version 0.10 is also avaible with this ppa
install nodejs with:
Thanks to my friend Julian Xhokaxhiu
FYI, according to this page in the wiki of the nodejs github repo, Chris Lea’s PPA (mentioned in several other answers) has been superseded by the NodeSource distributions as the main way of installing nodejs from source in Ubuntu:
This is supported for the three latest (at the time of writing this) LTS versions of Ubuntu: 10.04 (lucid), 12.04 LTS (precise) and 14.04 (trusty).
I’m not sure this will help in installing an old version of nodejs, but I’m putting this here in case it helps others who needed to install a specific (newer) version of nodejs that isn’t included in their distro’s repositories.
NOTE: you can use NVM software to do this in a more nodejs fashionway. However i got issues in one machine that didn’t let me use NVM. So i have to look for an alternative 😉
You can manually download and install.
go to nodejs > download > other releases http://nodejs.org/dist/
choose the version you are looking for http://nodejs.org/dist/v0.8.18/
choose distro files corresponding your environmment and download (take care of 32bits/64bits version). Example: http://nodejs.org/dist/v0.8.18/node-v0.8.18-linux-x64.tar.gz
Extract files and follow instructions on README.md :
To build:
Prerequisites (Unix only):
If your python binary is in a non-standard location or has a non-standard name, run the following instead:
To run the tests:
To build the documentation:
To read the documentation:
Maybe you want to (must to) move the folder to a more apropiate place like /usr/lib/nodejs/node-v0.8.18/ then create a Symbolic Lynk on /usr/bin to get acces to your install from anywhere.
And if you want different release in the same machine you can use debian alternatives. Proceed in the same way posted before to download a second release. For example the latest release.
Move to your favorite destination, the same of the rest of release you want to install.
Follow instructions of the README.md file. Then update the alternatives, for each release you have dowload install the alternative with.