n
Navigate forward in man pages
TLDR
Install a given version of node. If the version is already installed, it will be activated
Display installed versions and interactively activate one of them
Remove a version
Execute a file with a given version
Output binary path for a version
SYNOPSIS
n
n <version> | latest | lts | current
n [options] <version>
n rm <version ...>
n bin <version>
n exec <version> <command> [args...]
n prune
PARAMETERS
<version>
Specifies a Node.js version to install or use. Can be a specific version number (e.g., 16.14.0), latest, or lts.
-V, --version
Displays the version of the n utility itself.
-h, --help
Shows the command's help message and usage instructions.
lts
An alias to install or switch to the latest Long Term Support (LTS) version of Node.js.
latest
An alias to install or switch to the latest stable version of Node.js.
rm <version ...>
Removes one or more specified Node.js versions from the system.
prune
Cleans up cached Node.js versions that are no longer installed or used.
bin <version>
Prints the full path to the Node.js executable for the specified version.
exec <version> <command> [args...]
Executes a shell command using the specified Node.js version, useful for testing.
-q, --quiet
Suppresses verbose output during operations.
-p, --prefix <path>
Specifies the installation directory for Node.js versions. Default is /usr/local.
DESCRIPTION
n is a simple command-line utility for managing Node.js versions on Unix-like operating systems, primarily Linux and macOS. It provides a straightforward way to install, switch between, and remove different Node.js versions. Developed as a concise shell script, it offers a fast and minimalist alternative to other Node.js version managers like nvm or fnm. The utility simplifies the process of handling multiple Node.js environments, which is crucial for developers working on projects that require specific or varying Node.js runtime versions.
When a user specifies a version, n downloads the pre-built Node.js binaries directly from nodejs.org and installs them into a designated directory, commonly /usr/local or a user-defined prefix. This direct approach contrasts with managers that might rely on source compilation or complex environment manipulations. n automatically manages the symlinks in the target bin directory (e.g., /usr/local/bin) to point to the selected Node.js version. While powerful, users must ensure their system's PATH environment variable is correctly configured to include this bin directory for the node and npm commands to be accessible from any location. Its simplicity means it does not inject shell functions or modify startup scripts, making it a "set it and forget it" tool once the initial setup is complete. It supports installing the latest stable, LTS (Long Term Support), or any specific semantic version, alongside capabilities for removing old versions and executing commands with specific Node.js runtimes.
CAVEATS
n primarily targets Unix-like systems (Linux, macOS) and is not officially supported on Windows (though it can work in WSL).
It requires curl or wget for downloading Node.js binaries.
Installation into system-wide paths (e.g., /usr/local) typically requires sudo privileges.
n does not automatically manage the system's PATH environment variable; users must ensure the installation prefix's bin directory is included in their PATH.
It does not manage Node.js package managers (npm, yarn) separately; their versions are tied to the installed Node.js runtime.
INSTALLATION
n is commonly installed via npm (e.g., npm install -g n) or by directly cloning its Git repository and running the install script.
Ensure npm and Node.js are already available on your system before installing n via npm.
ENVIRONMENT CONFIGURATION
For node and npm commands to be globally accessible after using n, the directory where n installs Node.js binaries (defaulting to /usr/local/bin) must be included in your shell's PATH environment variable. This typically involves adding a line like export PATH="/usr/local/bin:$PATH" to your shell's configuration file (e.g., ~/.bashrc, ~/.zshrc).
HISTORY
n was created by TJ Holowaychuk as a simple, shell script-based alternative for managing Node.js versions. It gained popularity for its minimalist approach, contrasting with more feature-rich but potentially complex managers like nvm. Its development has focused on providing direct control over Node.js installations with minimal overhead, downloading pre-built binaries directly from nodejs.org. It has been actively maintained and continues to be a robust and straightforward tool for Node.js developers seeking efficiency and simplicity in managing their runtime environments.