
Setting Up NVM, PM2, and Process Management on Linux
Why NVM Over System Node? Don't apt install nodejs . You'll get a stale version pinned to your distro's release cycle, and switching between projects that need different Node versions becomes a mess. NVM gives you per-user Node version management with zero system-level conflicts. Install NVM curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash Reload your shell: source ~/.bashrc Verify: nvm --version # 0.40.1 Install Node.js # Install LTS nvm install --lts # Or a specific version nvm install 20.18.0 # Set default — without this, new shells may pick a different version nvm alias default 20.18.0 # Verify node -v && npm -v Where Does Node Live? NVM installs per-user. Your Node binary path looks like: /home/deploy/.nvm/versions/node/v20.18.0/bin/node This matters when PM2 needs to register a systemd service. Keep it in mind. Install PM2 npm install -g pm2 Since we used NVM, PM2 lives at: ~/.nvm/versions/node/v20.18.0/bin/pm2 Quick sanity check: pm2 --version PM2
Continue reading on Dev.to
Opens in a new tab




