Install Node.js and npm

With this step-by-step guide you can easily install Node.js and the corresponding package manager npm & check the installation afterwards.

Prerequisites

  • A server with Debian or Ubuntu as operating system
  • SSH root access



Node.js and NPM installation


To install Node.js in the desired version on your server, you can find the corresponding command under the following link: https://github.com/nodesource/distributions#installation-instructions


The following section describes the installation of Node.js version 20 and npm in the corresponding version 9.5.1.


All previous Node.js versions and the corresponding versions can be found at: https://nodejs.org/en/download/releases


First download the official Node.js package manager (NodeSource) and then start installing Node.js and the corresponding package manager npm.


Debian:

curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs


Ubuntu:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - && sudo apt-get install -y nodejs


Node.js and npm should then be successfully installed on your server.



Check installation

You can check the installation of Node.js and the associated package manager npm with the following commands:

Node.js

node -v
-> Output: v20.15.0 (or similar)

NPM

npm -v
-> Output: 10.7.0 (or similar)