Run the following command as a user with sudo privileges Use this repository if your application requires a specific version of Node.js.Īt the time of writing, NodeSource repository provides the following versions: It maintains an APT repository containing multiple Node.js versions. NodeSource is a company focused on providing enterprise-grade Node support. Installing Node.js and npm from NodeSource # Once done, verify the installation by running: nodejs -v v12.22.9
The command above will install a number of packages, including the tools necessary to compile and install native addons from npm.
Run the following commands to update the package index and install Node.js and npm: sudo apt update sudo apt install nodejs npm The installation is pretty straightforward. Installing Node.js and npm from the Ubuntu repository #Īt the time of writing, the Node.js version included in the default Ubuntu 22.04 repositories is v12.22.9 which is an older TLS version. If you are not sure which Node.js version to install, consult the documentation of the application you’re going to deploy. If you are Node.js developer, then this is the preferred way of installing Node.js.Ĭhoose the installation method that is most appropriate for your environment. This tool allows you to have multiple Node.js versions installed on the same machine. Currently, NodeSource supports Node.js v18.x, v17.x, v16.x, and v14.x. Use this repository to install a different Node.js version than the one provided in the Ubuntu repositories. The version included in the Ubuntu repositories is v12.22.9. This is the easiest way to install Node.js and npm on Ubuntu and should be sufficient for most use cases.
npm is the default package manager for Node.js and also the name of the world’s largest software registry. It is generally used to build fast and scalable server-side and networking applications.
Now we node.js installed and we are ready to create and deploy our first is a cross-platform, open-source JavaScript runtime environment built on Chrome’s JavaScript, designed to execute JavaScript code outside a web browser. In order to check which Node.JS version we have currently installed on our server, we should execute: # node -v Once Node.JS is installed, we will also install the node package manager (npm), which is the official package manager for Node.JS curl | sh Next, we will set the parameters so Node.JS is installed for the current user and run the installation.
Then, we switch to the latest-install folder and use curl to download the Node.js archive and then unpack it using tar. Then, we will create the directories required for the installation process: mkdir ~/ bashrc file: echo 'export PATH=$HOME/local/bin:$PATH' > ~/.bashrc First, we will change our current path to include ~/local/bin directory and then source the. In order to make sure that we have the latest version we are going to download the source, compile and install it, rather than using apt-get. However, the latest Node.js version might not be in the standard repository. The easiest one is to simply execute: # sudo apt-get install nodejs There are more different ways to install NodeJS. One curl is installed, we have all packages required prior to installing NodeJS. It is a library that lets us make HTTP requests in the command line. We also need to install curl the package. This package contains an informational list of packages which are considered essential for building Debian packages. Once we are done with the update, we need to install the build-essentials package. Before installing any package we should make sure that our repositories are up to date: # sudo apt-get update In order to install node.js on our Ubuntu server, we need to install some prerequisites first. Node.js contains a built-in HTTP server library, making it possible to run a web server without the use of external software, such as Apache or Nginx, and allowing more control of how the webserver works. Node.js utilizes JavaScript as its scripting language and achieves high throughput via non-blocking I/O and a single-threaded event loop. Node.js is a software platform that is used to build fast and easily scalable applications.