>_ blog · backend

How To Install Node.js 22 on Ubuntu and Run It in Production

Install Node.js 22 on Ubuntu the maintainable way and run your app as a restricted systemd service — with support dates and upgrade advice.

Version:Node.js 22 LTS
SupportedBy DevNextBD Team2 min read

What's different in Node.js 22 LTS

  • require() can load ES modules, which eases mixing CommonJS and ESM
  • Built-in WebSocket client and node --run for package.json scripts
  • Security support ends 30 April 2027 — plan your upgrade to 24 or 26 now

Supported until 30 April 2027

Node.js runs JavaScript on the server: APIs, real-time apps and build tools. This guide installs Node.js 22 (Maintenance LTS) on Ubuntu 24.04 or 26.04 from the NodeSource repository, then runs an app the production way — as a non-root systemd service that restarts on failure.

Which version should you use?

Production apps should use an LTS line. Even-numbered releases become LTS and receive about 30 months of fixes.

VersionReleasedStatus (Nov 2026)Security fixes until
265 May 2026Active LTS30 April 2029
246 May 2025Maintenance LTS30 April 2028
2224 April 2024Maintenance LTS30 April 2027

From Node.js 27, the project moves to one major release a year, and every release becomes LTS.

Prerequisites

  • A server running Ubuntu 24.04 or 26.04 (22.04 works too).
  • A user with sudo rights.

Step 1 — Add the NodeSource repository for Node.js 22

Ubuntu's own nodejs package is usually an older line. NodeSource publishes signed packages for every LTS line. Download the setup script, read it if you like, then run it:

Server
sudo apt update && sudo apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh
less nodesource_setup.sh
sudo -E bash nodesource_setup.sh

Step 2 — Install Node.js

Server
sudo apt install -y nodejs
node -v
npm -v
Output
v22.x.x

The package includes npm. Because the repository is pinned to the 22.x line, apt upgrade installs new 22.x security releases but never jumps to another major version.

Step 3 — Create a user for your app

Never run a web app as root. Create a system user that owns the app and nothing else:

Server
sudo useradd --system --create-home --home-dir /srv/myapp --shell /usr/sbin/nologin myapp
sudo -u myapp git clone https://github.com/you/myapp.git /srv/myapp/app
cd /srv/myapp/app && sudo -u myapp npm ci --omit=dev

Step 4 — Run it as a systemd service

Create /etc/systemd/system/myapp.service:

myapp.service
[Unit]
Description=My Node.js app
After=network.target

[Service]
User=myapp
WorkingDirectory=/srv/myapp/app
Environment=NODE_ENV=production
Environment=PORT=3000
ExecStart=/usr/bin/node server.js
Restart=on-failure
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/srv/myapp

[Install]
WantedBy=multi-user.target
Server
sudo systemctl daemon-reload
sudo systemctl enable --now myapp
journalctl -u myapp -f

Keep the app on 127.0.0.1:3000 and put a reverse proxy such as nginx in front of it for HTTPS.

Step 5 — Keep it patched

Server
sudo apt update && sudo apt upgrade -y
sudo systemctl restart myapp
npm audit --omit=dev

Upgrading to a newer major version later

Change the setup script number (for example setup_26.x), run it again, then sudo apt install -y nodejs. Run your test suite on the new version first — major releases remove deprecated APIs.

Conclusion

Node.js 22 is installed on Ubuntu and your app runs as a restricted systemd service. Node.js 22 receives security fixes until 30 April 2027; schedule the upgrade well before that date.

All versions of this guide

Each version is a complete guide written and tested for that release.

VersionStatusSupported untilGuide
Node.js 26 LTSCurrent30 April 2029Open
Node.js 24 LTSSupported30 April 2028Open
Node.js 22 LTSSupported30 April 2027You're reading this

#Node.js#Ubuntu#Linux#JavaScript