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.
npm install nNo compatibility data collected yet for this library.
Demonstrates global installation of 'n', installing and switching between Node.js versions, running commands with specific versions, and basic version management operations.
Install `jq` on your system for improved performance: `brew install jq` (macOS) or `sudo apt-get install jq` (Debian/Ubuntu).
If you require the old behavior where `corepack` is not preserved by default, set the `N_PRESERVE_COREPACK` environment variable to `0` or `false`.
Use 'n' within a supported environment such as macOS, Linux, or WSL. For native Windows Node.js version management, consider alternatives like `nvm-windows`.
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.
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`.
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`.
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.
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`.
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.