ni
Uses the right package manager automatically
TLDR
SYNOPSIS
ni [options] [packages...]nr [script] [args...]nlx package [args...]nun package...nup [options]ncina args...
DESCRIPTION
ni is a small command-line utility by Anthony Fu that dispatches package-manager commands to whichever package manager the current project uses: npm, yarn, pnpm, bun, or deno. The package manager is detected by looking at the lockfile in the project root (package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lock, bun.lockb, deno.json) or the packageManager field of package.json.Users type the same short commands regardless of project. ni installs dependencies, nr runs scripts, nlx executes a one-off package, nun removes packages, nup upgrades them, nci performs a clean install, and na passes arbitrary arguments straight through to the detected agent.Interactive menus are available when fzf is on the PATH: nr without arguments lists scripts, ni -i picks packages, and nr - reruns the previous script.
PARAMETERS
-D
Add as a development dependency (maps to --save-dev / -D).-P
Production-only install (prunes dev dependencies).-g
Operate on globally installed packages.-i
Interactive mode (select packages or scripts via fzf).--frozen
Install with a frozen lockfile (no updates).-C DIR
Run as if invoked from directory DIR.?
Show the translated command for the detected agent without running it.-v, --version
Print the ni version.-h, --help
Display help.
CONFIGURATION
User configuration lives in ~/.nirc:
globalAgent=npm
CAVEATS
On Windows PowerShell, the built-in ni alias for New-Item collides with this tool; remove it with Remove-Item Alias:ni -Force before using. A few legacy aliases have been renamed to avoid conflicts with other tools: nx/nix are now nlx, and nu is now nup. Because ni relies on lockfile detection, projects without any lockfile fall back to the defaultAgent.
HISTORY
Created by Anthony Fu (antfu) and first published to npm in 2021 under @antfu/ni. It was moved to the antfu-collective organization on GitHub and is distributed through npm (@antfu/ni) and Homebrew (brew install ni). The project is written in TypeScript.
