When working with Node.js, managing different versions efficiently is essential. Whether you’re running apps on servers or juggling multiple projects locally, a version manager simplifies your workflow.
Two of the most popular tools for this job are n
and nvm
. Each has its strengths, and choosing the right one depends on your environment and use case.
What Are They?
n
: A Node.js version manager designed for simplicity. It installs and manages Node.js system-wide, making it ideal for production servers or global development environments.nvm
: A per-user Node.js version manager that works at the shell level. It allows you to install multiple versions of Node.js in your user directory and switch between them seamlessly.
How to Install n
n
is not typically available from the default Debian repositories. To install it, use the following manual method:
0 1 2 3 4 5 6 |
sudo apt update sudo apt install -y curl build-essential curl -L https://raw.githubusercontent.com/tj/n/master/bin/n -o n bash n lts sudo mv n /usr/local/bin/ |
This will install the latest LTS version of Node.js and place the n
tool in your global PATH.
Once n
is installed, you can begin using it to manage Node.js versions system-wide.
Key Differences
Feature | n (Simple & Fast) | nvm (Project-Focused) |
---|---|---|
Scope | System-wide (global) | Per-user (local) |
Ease of Use | Super fast and minimal | Requires shell integration |
Best For | Servers, global use, simplicity | Developers working on many projects |
Project .nvmrc Support | Not built-in | Yes (great for per-project version pinning) |
Speed | Very fast version switching | Slightly slower due to shell dependency |
Dependencies | None | Requires .bashrc /.zshrc setup |
Multi-user Support | Yes (all users share versions) | No (each user installs their own) |
Why Use n
?
If you’re deploying Node.js apps on a server, managing containers, or just want to get things done quickly, n
is a great choice. It doesn’t require any profile modification, and switching Node versions is instant.
0 1 2 3 4 5 |
sudo n 12 # Installs and switches to Node.js v12 sudo n lts # Switch to the latest LTS version sudo n latest # Install and use the latest available Node.js sudo n 18 # Install Node.js v18 |
After installation, n
keeps all installed versions available. To list them:
0 1 2 3 4 5 6 7 8 |
n # You'll get an interactive list like: # o 12.22.12 # 14.21.3 # 16.20.2 # o 18.17.1 # Use up/down arrows to choose a version to activate |
To remove older versions and free up space:
0 1 2 |
sudo n prune |
To re-use a specific version later:
0 1 2 |
sudo n 14 |
To reinstall and recompile a specific version:
0 1 2 |
sudo n reinstall 16.20.2 |
To install a version without switching to it:
0 1 2 |
sudo n add 14.21.3 |
With n
, you control your environment system-wide with minimal effort — no need to tweak shell profiles or source files every time.
Why Use nvm
?
For local development, especially when working on multiple projects with different Node versions, nvm
shines. It supports .nvmrc
files, which makes team collaboration and version consistency easier.
0 1 2 3 |
nvm install 18 # Installs Node.js v18 nvm use # Uses the version specified in .nvmrc |
Which One Should You Choose?
- Use
n
if:- You need to manage Node.js globally (e.g., on a server or CI/CD system).
- You prefer simplicity and speed.
- You’re setting up Docker or system-wide environments.
- Use
nvm
if:- You’re working across multiple Node.js projects.
- You want to isolate Node.js versions per user or project.
- You rely on
.nvmrc
for team collaboration.
Final Thoughts
Both n
and nvm
are excellent tools. If you’re looking for speed and ease of use, go with n
. If you need per-project flexibility and development isolation, nvm
is the better choice.
For developers or sysadmins who’ve had frustrating experiences with nvm
, n
can feel like a breath of fresh air, quick, reliable, and easy to maintain.
Choose the one that fits your workflow and enjoy smoother Node.js development.