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.

install· Homebrew

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

# via Homebrew
brew install ni

Alternatives & related tools

add a badge to your README

Maintain ni? Show that it's featured on trmn. The badge links back to this page.

Featured on trmn
Markdown
[![Featured on trmn](https://www.trmn.sh/badge/ni.svg)](https://www.trmn.sh/tools/ni?utm_source=badge)
HTML
<a href="https://www.trmn.sh/tools/ni?utm_source=badge"><img src="https://www.trmn.sh/badge/ni.svg" alt="Featured on trmn" height="20"></a>