Node.js runs JavaScript outside a browser. On Linux, choose an installation method and maintained version that match the operating system, application and intended service user.
Install Node.js using the default package manager
On supported Debian or Ubuntu systems:
sudo apt update
sudo apt install nodejs npmOn a supported RPM-based system with appropriate packages available:
sudo dnf install nodejs npmCheck node –version and npm –version. Distribution versions can differ from upstream releases; verify that both the platform and runtime remain maintained. CentOS Linux 7 and 8 are retired and need a supported platform migration.
Install Node.js using NodeSource repository
If the distribution package is unsuitable, check NodeSource’s current repository instructions for the actual OS and selected maintained release line. Download and review any setup script before running it with administrative privileges.
Do not use the old Node.js 18 setup URL or assume changing a repository is harmless to an existing application. Review package replacement and test compatibility first.
Install Node.js using NVM (Node Version Manager)
NVM manages Node.js per user and per shell. Follow its official installation instructions for a reviewed tagged release, then open a new shell or load the documented initialisation.
With NVM loaded as the intended application user:
nvm install --lts
nvm use --lts
node --version
npm --versionChoose a specific maintained version if the application requires it. The newest current release is not always the appropriate long-term-support choice.
Run an application consistently
Record the runtime version and executable path used by the service. A systemd service does not automatically load an interactive user’s NVM shell configuration. Keep the deployment method consistent and test upgrades before changing the live runtime.