# ni

> Detects a project's package manager from its lockfile and translates ni, nr, nlx, nup, nun, nci commands for npm, yarn, pnpm, bun, deno, nub and aube.

Stars: 8.3k · Language: TypeScript · License: MIT · Categories: Dev Tools

- Repository: https://github.com/antfu-collective/ni
- Page: https://www.trmn.sh/tools/ni

## Install

- Homebrew: `brew install ni`

## Overview

ni is a set of short commands that wrap JavaScript package managers. Before running, it inspects the project for lock files and workspace files (yarn.lock, pnpm-lock.yaml, package-lock.json, bun.lock, bun.lockb, deno.json, nub.lock, aube-lock.yaml, and others) or the `packageManager` field in package.json. It then runs the equivalent command for npm, yarn (1 and Berry), pnpm, bun, deno, nub or aube. Detection and command mapping use the package-manager-detector library.

The commands cover the usual dependency tasks: `ni` installs (`ni vite`, `ni -D`, `-P` for production only, `--frozen`, `-g` for global, `-i` for interactive selection), `nr` runs scripts (`nr dev --port=3000`, `nr -` to rerun the last script, `nr -p` to pick a package and script), `nlx` downloads and executes packages (`--local` prefers a local binary), `nup` upgrades (`-i` for interactive), `nun` uninstalls, `nci` does a clean install, `nd` dedupes, and `na` is a bare alias for the detected agent. Appending `?` to a command prints the resolved command instead of running it, and `-C <dir>` changes directory first.

In pnpm workspaces with catalogs, Yarn Berry workspaces with catalogs, or Bun workspaces with catalogs, `ni` switches to catalog mode. It writes `catalog:` references into package.json and updates the workspace catalog, prompting for a catalog when the package isn't in one. Configuration lives in `~/.nirc` or `NI_*` environment variables. Options include `defaultAgent`, `globalAgent`, `runAgent=node` (uses `node --run`, needs Node.js 22+), `useSfw`, and `catalog`. Setting `NI_AUTO_INSTALL=true` installs a missing package manager globally before running the command. Shell completions are available for bash, zsh and fish.

It is aimed at JavaScript and TypeScript developers who move between projects that use different package managers. On Windows PowerShell, the built-in `ni` alias for `New-Item` must be removed for the tool to work.

### Installation

```bash
# via Homebrew
brew install ni
```

## Alternatives

- [concurrently](https://www.trmn.sh/tools/concurrently.md): Node.js CLI that runs multiple shell commands in parallel with prefixed, colored output and options to kill or restart processes. Works on Windows. (TypeScript, 7.9k stars)
- [serve](https://www.trmn.sh/tools/serve.md): Node.js CLI that serves a static site, single page application, or single file over HTTP, with a browsable directory listing UI. (TypeScript, 9.9k stars)
- [npm-check-updates](https://www.trmn.sh/tools/npm-check-updates.md): CLI that upgrades package.json dependencies to their latest versions, preserving semver range operators. Works with npm, yarn, pnpm, deno, and bun. (TypeScript, 10.3k stars)
- [clasp](https://www.trmn.sh/tools/clasp.md): Command-line tool for developing Google Apps Script projects locally: push/pull code, manage versions and deployments, tail logs, and run functions. (TypeScript, 5.9k stars)
- [Prism](https://www.trmn.sh/tools/prism.md): Command-line HTTP server that mocks APIs from OpenAPI v2/v3.x and Postman Collections, and proxies traffic to validate it against the spec. (TypeScript, 5.1k stars)

---

Canonical: https://www.trmn.sh/tools/ni
