Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Install Node.js With NVM on a VPS

Install Node.js per user with NVM on a VPS, pin the version your application supports, make it persist across SSH sessions, and configure non-interactive services correctly.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to install Node.js on a VPS without replacing the distribution’s packages is to install NVM as the same non-root user that will run your application, reload that user’s shell, install either the current LTS line or a pinned release, and set a default alias. A complete first setup is:

sudo apt update
sudo apt install -y curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash
source ~/.bashrc
nvm install --lts
nvm alias default lts/*
node -v
npm -v

NVM is a per-user, per-shell version manager. It keeps Node.js versions in the account’s home directory, lets you switch between them, and does not replace a system-wide Node installation. The shell profile and the execution context of your service still matter, so the procedure below covers login shells, project version files, non-interactive services, source builds, and the common nvm: command not found failure.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What NVM changes on a VPS

NVM (Node Version Manager) installs Node.js under the home directory of one Unix account and exposes the nvm command as a shell function. That scope is useful on a VPS: you can run an application user’s supported Node release without changing packages used by the operating system, and you can keep more than one Node release available for different projects.

The separation is also the most important operational detail. NVM is not a system daemon and it is not automatically global. An installation performed as root belongs to root’s home directory; it will not appear when another account connects over SSH. Likewise, a version selected in one shell is not necessarily selected in a new shell, a cron job, or a service manager. You must configure the account and execution context that actually runs the application.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Check the VPS before installing

Use the deployment account

Log in as the non-root account intended to own the application and run its processes. Use sudo only for operating-system package tasks. Installing NVM as that account keeps its files, Node versions, npm global packages, and shell settings together in one home directory.

Identify the operating system and architecture

The commands in this guide target a Debian or Ubuntu VPS with a POSIX shell and sudo access. NVM normally downloads a prebuilt Node binary for mainstream Linux combinations. An unsupported CPU architecture or a musl-based distribution can instead trigger a source build. On a small VPS, compiling Node.js can take substantially longer than unpacking a binary, so check available memory, disk space, and build tools before starting a source installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Confirm which shell profile is used

The installer attempts to add an NVM loader to the profile associated with your account. Bash commonly reads ~/.bashrc for interactive shells, but an account may use another profile. The profile must define NVM_DIR and load nvm.sh before the nvm function exists.

Install prerequisites on Debian or Ubuntu

Refresh package metadata and install curl while logged in as the deployment user:

sudo apt update
sudo apt install -y curl

apt update refreshes the local package index; it does not install Node.js. Installing only curl keeps the operating-system step separate from the per-user NVM installation. If your VPS image uses a different package manager, use that distribution’s method to provide curl and keep the remaining shell steps unchanged.

Install the versioned NVM script

Run the versioned installer documented by the nvm project from the account that will run Node:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash

The version in the URL is intentional. Pinning the installer revision makes provisioning easier to reproduce than using an unversioned, moving target. In a security-sensitive environment, download the script for review and execute the reviewed copy rather than piping an unexamined response directly to a shell.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

During installation, NVM is placed beneath the user’s home directory (or the XDG configuration directory when that setting is used). The installer tries to append a loader like this to the appropriate profile:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"

The loader does not install a Node version by itself. It makes the nvm shell function available after the profile is read.

Reload the shell and verify NVM

Open a new SSH session, or reload the profile explicitly. For a Bash account whose loader was written to ~/.bashrc:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
source ~/.bashrc

If your account uses another profile, source that file instead. Then verify both command discovery and the installed NVM revision:

command -v nvm
nvm --version

command -v nvm should report nvm. Because NVM is a shell function, checking with which nvm can be misleading on some systems; use command -v as shown. If the command is still unavailable, work through the troubleshooting section below before attempting another Node installation.

Install the Node.js release your application supports

Install the current LTS line

For an application that follows the currently designated long-term-support line, run:

nvm install --lts

The --lts alias resolves when you run the command, so it is convenient for a new server but does not describe one immutable version forever. Record the resolved version in your deployment documentation if repeatable builds require a fixed runtime.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Install a major line or exact release

Use a major version when your support policy follows that line:

nvm install 22

Use an exact release when the application, lockfile, or deployment policy requires it:

nvm install 22.14.0

Choose a version supported by the application rather than assuming that the newest release is appropriate. NVM can keep multiple installed versions, so you can install a second release for a migration or a separate project without removing the first.

Inspect installed versions and switch temporarily

nvm ls
nvm use 22
node -v
npm -v

nvm ls lists versions installed for this account. nvm use 22 changes the current shell’s PATH to the selected major line; use an exact version if two releases share that major. The final two commands verify the executables that the shell will actually run. Check both because npm is installed alongside the selected Node distribution and is the package manager your deployment scripts will invoke.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the choice persistent for new sessions

The first Node version you install becomes the default unless you change the alias. Set an explicit default after selecting the version your application should use:

nvm alias default 22

Replace 22 with the major or exact version you selected. New login shells for this account will select that alias when the NVM loader runs. The alias does not rewrite project files and does not override a deliberate nvm use in a shell; it supplies the fallback for sessions that do not make another selection.

After setting it, start a fresh SSH session and verify:

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
node -v
npm -v
nvm current

Testing in a new connection catches profile mistakes that are hidden when an old shell still has a previous PATH in memory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Pin a project’s version with .nvmrc

A project can carry its desired Node release in a file named .nvmrc at its root. For example, write the major or exact version approved by your application policy:

printf '%sn' 22.14.0 > .nvmrc

From that directory, run:

nvm use

NVM reads .nvmrc and switches to the recorded version, provided that version is already installed. If it is not installed, install it first with nvm install while in the project directory; NVM can use the version named by the file. Keep the file aligned with the application’s lockfile and deployment policy. A version file is a request for a runtime, not a substitute for testing dependency compatibility.

Use NVM correctly in services, cron, and deployment scripts

Interactive SSH behavior is not the same as a non-interactive process. NVM is a shell function loaded by nvm.sh; a service unit, cron job, or deployment hook may not read ~/.bashrc. If such a process runs node without loading NVM, it may report “command not found” or use a different system installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Source NVM explicitly in a shell script

A deployment script can load NVM before invoking Node:

export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use 22
node /path/to/app/server.js

Use the actual application user’s home directory and the version required by the project. If the project has an .nvmrc, run cd into the project and use nvm use instead of hard-coding a second version.

Invoke the selected binary by full path

For services that should not depend on shell initialization, resolve the selected Node path after installing the version:

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
nvm which 22

Use the returned absolute path in the service configuration or wrapper script, and retest after changing the Node version. This approach makes PATH precedence explicit, but the path changes when you move the service to another NVM version, so update the unit as part of the upgrade.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Test the exact execution context

Run the same user, working directory, environment, and command used by the service. A successful node -v in your SSH shell proves only that your interactive shell is configured; it does not prove that the service manager inherited that configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot the common failures

“nvm: command not found”

  1. Start a new shell or reconnect over SSH so the profile is read again.
  2. Source the profile that should contain the loader, such as source ~/.bashrc.
  3. Check that the NVM script exists and is readable: ls -l "${NVM_DIR:-$HOME/.nvm}/nvm.sh".
  4. Inspect the profile for the NVM_DIR export and the line that sources nvm.sh.
  5. If the installer edited the wrong file, set PROFILE to the intended profile and rerun the versioned installer.

Do not install NVM again as root to fix a missing command for another user. Correct the target account’s profile and home-directory permissions instead.

NVM works over SSH but not in a service

This usually means the service did not load the shell profile. Source nvm.sh in the service’s wrapper, or configure the service to execute the absolute Node path returned by nvm which. Confirm the service runs as the same account that owns the NVM directory.

The wrong Node version appears after reconnecting

Run nvm alias default to inspect the default, then set it explicitly with nvm alias default <version>. Check for an application-level .nvmrc and for a distribution-provided Node earlier in PATH. Reconnect and run node -v again; an existing shell will not retroactively adopt a changed alias.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An installation starts compiling from source

Unsupported architectures and musl-based systems may not have a matching prebuilt binary. On Debian or Ubuntu, a source build may require the compiler toolchain and OpenSSL headers:

sudo apt update
sudo apt install -y build-essential libssl-dev

Compilation consumes CPU, memory, disk, and time. Small VPS plans can appear stalled while the compiler works. Watch resource usage, allow sufficient temporary disk space, and prefer a supported prebuilt combination when your architecture and distribution permit it.

System Node and NVM Node are mixed

If the VPS already has a distribution-provided Node installation, nvm use system selects it when available. nvm deactivate restores the PATH state that existed before NVM was activated. Mixing apt-managed and NVM-managed Node is possible, but document which one has precedence and make the choice explicit in service and deployment scripts.

NVM compared with other installation approaches

The right approach depends on whether you need per-user isolation, multiple runtimes, or a system-managed service. These differences are operational rather than a claim that one method is universally faster or safer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Approach Scope Multiple Node versions Version pinning Shell and service behavior Updates
NVM Per user, under the user’s home directory Install and switch among multiple versions Major or exact versions, plus .nvmrc Interactive shells load a function; services must source NVM or use an absolute path Install a new version with NVM and move the default alias or service path
Distribution packages System-wide package manager scope Usually centered on the distribution’s packaged selection Constrained by repository packaging and release policy Available to services without NVM initialization Managed through the operating system’s package updates
System-wide Node installer Shared installation for the operating system Requires separate system-wide management for parallel versions Depends on the installer’s release and repository controls Available globally, but PATH changes affect every account Upgrade the shared installation and retest all applications

NVM is a strong fit when one VPS hosts projects with different Node requirements or when application ownership should remain separate from system packages. A distribution package can be simpler for a single service that must be managed entirely by the operating system. Whichever method you choose, avoid an undocumented mixture: record the expected binary path and version in deployment configuration.

Security and maintenance practices

  • Run the installer as the application account. Use root only for prerequisite packages or build dependencies.
  • Keep the installer revision pinned. The versioned URL makes provisioning repeatable; review downloaded scripts in security-sensitive environments.
  • Pin the runtime deliberately. Use an exact version or a documented LTS policy when reproducibility matters, and update the default alias as part of a planned change.
  • Keep runtime and lockfile decisions together. A Node upgrade can affect native modules and dependency resolution even when application source code is unchanged.
  • Re-test non-interactive execution after upgrades. A new NVM version changes the absolute Node path, so service units and wrappers that use full paths may need an edit.
  • Document PATH precedence. State whether the application uses NVM, the system package, or nvm use system; this prevents an unnoticed switch after an image update.

A repeatable installation checklist

  1. Connect as the non-root account that will run the application.
  2. Confirm the VPS distribution, architecture, shell, home directory, and available resources.
  3. On Debian or Ubuntu, run sudo apt update and install curl.
  4. Run the versioned NVM installer: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.8/install.sh | bash.
  5. Open a new shell or source the profile containing the NVM loader.
  6. Verify with command -v nvm and nvm --version.
  7. Install the application’s current LTS, major, or exact Node release.
  8. Check nvm ls, then verify node -v and npm -v.
  9. Set nvm alias default <version> for new login shells.
  10. Add an .nvmrc when the project needs a recorded runtime, and keep it aligned with the lockfile.
  11. Configure services and deployment jobs to source nvm.sh or call the selected Node binary by its full path.
  12. If NVM falls back to source compilation, install the required build packages and allow for the VPS’s resource limits.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.