# 使用 Homebrew, MacPorts 安装 n

查看 n 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:n
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install n
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install n
```

  证据: MacPorts ports tree: devel/n/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:n
- **软件包管理器:** Homebrew
- **软件包管理器页面:** <https://formulae.brew.sh/formula/n>
- **版本:** 10.2.0
- **来源摘要:** Node version management
- **主页:** <https://github.com/tj/n>
- **仓库:** <https://github.com/tj/n>
- **上游文档:** <https://github.com/tj/n#readme>
- **许可证:** MIT
- **源码归档:** <https://github.com/tj/n/archive/refs/tags/v10.2.0.tar.gz>
- **已生成:** 2026-07-08T07:18:31+00:00

## 可执行文件

- n (cli)
- n (别名)

## 安装行为

- post-install 钩子: 未定义
- Bottle: 可用 于 all

## 版本和新鲜度

- 页面生成时间: 2026-07-08
- 管理器版本: 10.2.0
- 本地数据: OK
- 上游仓库: https://github.com/tj/n
- 检测到的最新版本: v10.2.0 (当前)
- 信息: No package-manager update timestamp was available.
## 项目历史与用法

n is a long-lived Node.js version manager by TJ Holowaychuk. The GitHub repository and npm package both date to January 5, 2011, placing it in the early era when Node users needed fast local switching between rapidly moving Node releases. It remains a small, Unix-style tool rather than a broader runtime manager: install a version, keep downloaded versions in a cache, and switch the active Node in place.

### 项目历史

The project is implemented primarily as shell code and distributed through npm, Homebrew, MacPorts, and direct script installation. Release v10.2.0 was published on GitHub on May 21, 2025 and is also the stable Homebrew version. The project has continued to adapt to Node ecosystem changes, including LTS aliases, package.json engine resolution, custom mirrors, alternate architectures, and preservation of npm/corepack during Node installs.

### 采用历史

n has broad practical adoption among developers who want a simpler alternative to shell-integrating version managers. The GitHub API showed 19,516 stars and 764 forks on July 1, 2026. npm reported 1,667,021 downloads for May 30, 2026 through June 28, 2026, and Homebrew reported 9,495 installs in the preceding 365 days. Those numbers reflect different distribution channels: npm is the dominant installation path, while Homebrew remains a convenient macOS/Linux route.

### 使用方式

The common workflow is `n lts`, `n latest`, or `n 20` to install and switch Node, with bare `n` opening the interactive selector over cached versions. Package nerds use `n run`, `n exec`, and `n which` when they need to run commands under a cached Node without changing the active install. The `engine` label is useful in repos that declare a Node range in package.json, while `N_NODE_MIRROR`, `N_ARCH`, `--offline`, and `--cleanup` cover mirrors, architecture-specific downloads, air-gapped/cache use, and container one-shot installs.

### 为什么软件包爱好者会关心

n matters because it is intentionally narrow: it manages Node versions without trying to own the whole shell session or project environment. That makes it especially handy on CI images, disposable containers, remote shells, and machines where a global Node install is acceptable. The tradeoff is also the reason people still compare it with nvm/fnm/asdf/Volta: n changes the active installed Node rather than providing per-directory shims by default.

### 时间线

- 2011-01-05: GitHub repository and npm package created.
- 2025-05-21: v10.2.0 published on GitHub.
- 2026-05-30 to 2026-06-28: npm reported 1,667,021 downloads.
- 2026-07-01: GitHub API showed 19,516 stars and Homebrew API showed 9,495 installs over 365 days.

### Related projects

- Node.js
- npm
- nvm
- fnm
- Volta
- asdf

### 来源

- <https://api.github.com/repos/tj/n>
- <https://api.npmjs.org/downloads/point/last-month/n>
- <https://formulae.brew.sh/api/formula/n.json>
- <https://formulae.brew.sh/formula/n>
- <https://github.com/tj/n>
- <https://github.com/tj/n/releases>
- <https://registry.npmjs.org/n>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals

## 源数据库详情

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** n
- **Version Scheme:** 0
- **Revision:** 0
- **Head Version:** HEAD
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** head, stable

## 其他软件包管理器记录

- MacPorts - n: normalized package name match | MacPorts ports tree: devel/n/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1


## 相关链接

- [Source-control packages](https://www.automicvault.com/zh-hans/pkg/source-control-tools/) - Belongs to a source-control command family.
- [Terminal utility packages](https://www.automicvault.com/zh-hans/pkg/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Language runtime packages](https://www.automicvault.com/zh-hans/pkg/language-runtime-packages/) - Matched language runtime, compiler, or interpreter metadata.
- [Networking and protocol packages](https://www.automicvault.com/zh-hans/pkg/networking-protocol-tools/) - Matched network, protocol, or remote-service metadata.
- [plenv](https://www.automicvault.com/zh-hans/pkg/brew/plenv/) - Shares av.db curated category or tags: cli, language-runtime, runtime, shell, version-manager.
- [node](https://www.automicvault.com/zh-hans/pkg/brew/node/) - Shares av.db curated category or tags: cli, javascript, language-runtime, nodejs, runtime.
- [coffeescript](https://www.automicvault.com/zh-hans/pkg/brew/coffeescript/) - Shares av.db curated category or tags: cli, javascript, language-runtime, nodejs.
- [deno](https://www.automicvault.com/zh-hans/pkg/brew/deno/) - Shares av.db curated category or tags: cli, javascript, language-runtime, runtime.
- [duktape](https://www.automicvault.com/zh-hans/pkg/brew/duktape/) - Shares av.db curated category or tags: cli, javascript, language-runtime, runtime.
- [fibjs](https://www.automicvault.com/zh-hans/pkg/brew/fibjs/) - Shares av.db curated category or tags: cli, javascript, language-runtime, runtime.
- [pyenv](https://www.automicvault.com/zh-hans/pkg/brew/pyenv/) - Shares av.db curated category or tags: cli, language-runtime, shell, version-manager.
- [quickjs](https://www.automicvault.com/zh-hans/pkg/brew/quickjs/) - Shares av.db curated category or tags: cli, javascript, language-runtime, runtime.
- [n](https://www.automicvault.com/zh-hans/pkg/npm/n/) - Same normalized package name appears in another local ecosystem. Shared terms: manager, node, version.
- [n](https://www.automicvault.com/zh-hans/pkg/npm/n/) - Same normalized package name in another local ecosystem.

## Combined YAML source

View the package source record on GitHub. [combined/n.yml](https://github.com/automic-vault/db/blob/main/combined/n.yml)


## 来源

- Nucleus package database
- Geiger risk classifier
- package-page enrichment
- curated package history
- package version freshness
- av.db category and tag curation
- package relationship graph
- external package-manager database matches
- cross-ecosystem install command graph
