Skip to main content
Node.js is a JavaScript runtime that allows you to run JavaScript on the server side. npm is the default package manager for Node.js.
1

Update package lists

First, update your package lists to ensure you have the latest information:
sudo apt update
2

Install Node.js and npm

Install Node.js and npm using the apt package manager:
sudo apt install nodejs npm -y
This command installs both Node.js and npm together.
3

Verify Node.js version

Check that Node.js was installed successfully:
node -v
You should see output similar to v18.17.0.
4

Verify npm version

Check that npm was installed successfully:
npm -v
You should see output similar to 9.6.7.

Alternative: Install specific version

If you need a specific version of Node.js, you can:
  1. Install NodeSource repository:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
  1. Install Node.js:
sudo apt-get install -y nodejs

Next Steps

Now that Node.js and npm are installed, you can:
  • Create new Node.js projects with npm init
  • Install packages with npm install
  • Run Node.js applications
  • Use npm scripts for automation

Build docs developers (and LLMs) love