If we want to install the latest LTS (Long term support) Node.js version we can use this command adding the –lts flag at the end: nvm install –lts You will notice that the latest available version is now installed on our server. If we now check the Node.js version with: node -v Now to install the latest Node.js version we can simply run: nvm install node Installing Node.js and switching versions This will print a large list of all the available versions for Node.js starting from version v0.1.14 to the latest version currently available. For example, you can use the following command to check all the available versions for Node.js: nvm list-remote The npm can be used to install different Node.js versions.
bashrc file as an argument for the changes to apply.Īfter the installation has finished, we can check if nvm has been installed with the following commands: nvm –version We use the first command to download and execute the script that installs nvm and with source ~/.bashrc, we are running the source command with. You can now go ahead and install nvm using the following commands: curl -o- | bash
You can do this by running the following commands: apt-get update -y Additionally, replace ‘root’ with the username of the admin account if necessary.īefore starting, you have to make sure that all Ubuntu OS packages installed on the server are up to date. Log in and update the systemįirst, you will need to, log in to your Ubuntu 20.04 server via SSH as the root user: ssh -p Port_number You will need to replace ‘IP_Address‘ and ‘Port_number‘ with your server’s respective IP address and SSH port number. Access to the root user account (or access to an admin account with root privileges)įor this example we will be using Ubuntu 20.04 as the default OS, Node.js can be also installed and run on many different distributions.Installing Node.js and switching versions.
Run the following command to see where npm will install global packages to verify it is correct. There was a bug in some versions of npm that kept this from working, so you may need to go in and fix that up by hand. When npm is used to install itself, it is supposed to copy this special builtin configuration into the new install. The Node installer installs, directly into the npm folder, a special piece of Windows-specific configuration that tells npm where to install global packages.
(See also the point below if you're running Windows 7 and don't have the directory %appdata%\npm.) A brief note on the built-in Windows configuration
You can go and download it here - or stick with the manual path outlined below.īy default, npm is installed alongside node in Microsoft wrote a small command line tool to automate the steps below.