# Install Node.js

# Prerequisites

  • A working Linux server machine
  • You are logged in as a non-root user with sudo privileges

# Installation

Binary distributions of Node.js are provided by NodeSource. Installing Node.js on Debian Linux via the NodeSource distributions is an officially supported method.

First, install curl.

sudo apt update
sudo apt install -y curl

Assume the root user.

sudo -s

Install the latest LTS Node.js release via NodeSource.

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

Exit the root user shell.

exit

Make sure Node.js is installed correctly by getting its version number.

node -v

It should display something like:

v18.16.0

# Create an App Directory

To stay organized, I recommend creating a directory to store any apps you might deploy.

mkdir ~/apps

You are now ready to run and serve Node.js apps. You may choose to write and/or run completely custom Node.js apps, or you may choose to go with a framework like Next.js.