{"id":14718,"library":"n","title":"n – Node.js Version Manager","description":"n is a command-line interface (CLI) tool designed for interactively managing Node.js versions on Unix-like systems, including macOS and Linux (with WSL support). It distinguishes itself from alternatives like nvm by avoiding subshells and complex profile setups, offering a simple and direct approach to switching Node.js environments. The current stable version is 10.2.0, with minor and patch releases occurring every few weeks to months, and major versions less frequently, typically driven by significant internal changes or feature additions. Key differentiators include its simplicity, direct control over installed Node.js binaries, and a lack of shell modification, making it a straightforward choice for developers who prefer minimal environmental interference. It caches Node.js versions locally and allows for quick installation and activation of different versions.","status":"active","version":"10.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/tj/n","tags":["javascript","nvm","node","version","manager","switcher","binary","env"],"install":[{"cmd":"npm install n","lang":"bash","label":"npm"},{"cmd":"yarn add n","lang":"bash","label":"yarn"},{"cmd":"pnpm add n","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used preferentially for reading 'engines' from package.json since v10.0.0 for improved performance and reliability; n will fall back to using 'node' if 'jq' is not available.","package":"jq","optional":true}],"imports":[],"quickstart":{"code":"# Install n globally using npm (requires Node.js to be pre-installed or n to be bootstrapped first)\nnpm install -g n\n\n# Or, bootstrap install if npm/Node.js is not yet available, then install n\n# curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s install lts\n# npm install -g n\n\n# Install the latest LTS (Long Term Support) version of Node.js\nn lts\n\n# Install a specific Node.js version (e.g., 18.17.1)\nn 18.17.1\n\n# Switch to a specific Node.js version interactively\nn\n# Use arrow keys to select and Enter to activate\n\n# Run a command with a specific Node.js version without changing the global default\nn use 18.17.1 my-script.js\n\n# See currently installed Node.js versions and the active one\nn ls\n\n# Remove a specific Node.js version\nn rm 14.17.6\n\n# Clean up cached versions not currently in use\nn prune\n\n# Install the latest stable version of Node.js\nn latest","lang":"bash","description":"Demonstrates global installation of 'n', installing and switching between Node.js versions, running commands with specific versions, and basic version management operations."},"warnings":[{"fix":"Install `jq` on your system for improved performance: `brew install jq` (macOS) or `sudo apt-get install jq` (Debian/Ubuntu).","message":"Starting with v10.0.0, 'n' can optionally use `jq` for reading `engines` from `package.json` files, improving performance and robustness. While it falls back to Node.js if `jq` is absent, its presence might be assumed or preferred for optimal operation, potentially leading to slight behavioral changes for users without `jq` installed.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"If you require the old behavior where `corepack` is not preserved by default, set the `N_PRESERVE_COREPACK` environment variable to `0` or `false`.","message":"In v9.0.0, the `--preserve` option now also preserves `corepack` by default. This alters previous behavior where `corepack` might not have been preserved during Node.js version switches, potentially affecting workflows that rely on specific `corepack` configurations.","severity":"breaking","affected_versions":">=9.0.0"},{"fix":"Use 'n' within a supported environment such as macOS, Linux, or WSL. For native Windows Node.js version management, consider alternatives like `nvm-windows`.","message":"'n' does not officially support native Microsoft Windows shells (like PowerShell or CMD), nor Git for Windows BASH or Cygwin. It is designed for macOS, Linux, and other Unix-like systems, including Windows Subsystem for Linux (WSL).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Either install 'n' using `sudo npm install -g n`, change the ownership of `/usr/local/bin` and other relevant directories (`sudo chown -R $(whoami) /usr/local/bin`), or specify a custom install location using the `N_PREFIX` environment variable.","message":"The default installation location for 'n' is typically `/usr/local`, which often requires superuser (sudo) permissions for installation and managing Node.js versions. Installing without correct permissions can lead to `EACCES` errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run `n doctor` to diagnose potential issues, particularly those related to multiple `npm` locations. Ensure your PATH environment variable prioritizes the Node.js `bin` directory managed by `n`.","message":"During `n install` operations, especially after `npm install -g n`, it's possible for multiple `npm` installations to exist on the system if previous Node.js installations were done manually or via other managers. This can lead to unexpected behavior or `npm` not being found after a version switch.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use `sudo npm install -g n` or `sudo n <version>`, or adjust directory ownership with `sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share`.","cause":"Attempting to install 'n' or Node.js versions into system directories without sufficient permissions.","error":"EACCES: permission denied, mkdir '/usr/local/n'"},{"fix":"Ensure the directory where 'n' was installed (e.g., `/usr/local/bin` or a custom `N_PREFIX` location) is correctly included in your shell's PATH. Restart your terminal session after installation.","cause":"'n' executable is not in your system's PATH environment variable after installation.","error":"n: command not found"},{"fix":"Verify that a Node.js version is active using `n ls`. If npm is missing, you might need to reinstall the Node.js version (`n install <version>`) or check for conflicting npm installations using `n doctor`.","cause":"The npm binary associated with the currently active Node.js version is not in your PATH or was not properly installed with the Node.js version.","error":"npm: command not found"},{"fix":"Check your network connectivity. If persistent, try updating `curl` to its latest version. In some cases, `n` might be sensitive to older `curl` versions (e.g., issues with `--compressed` in `curl` 8.7.1 were fixed in `n` v9.2.3). Ensure there are no proxy issues interfering with downloads.","cause":"This error can occur if `curl` has issues with specific options or if the download URL generated by `n` is malformed or inaccessible (e.g., due to network issues, or specific `curl` versions).","error":"curl: (3) URL using bad/illegal format or missing URL"}],"ecosystem":"npm"}