Clean install with `nci`
mainnci to perform a clean installation (e.g., npm ci or pnpm install --frozen-lockfile).ncirepository·main·Indexed 27 days ago
https://github.com/antfu-collective/niA CLI tool that automatically detects and uses the correct package manager (npm, yarn, pnpm, bun, or deno) for a project based on its lockfiles. It provides a unified interface for common tasks: ni for installing/adding packages, nr for running scripts, nlx for executing packages, nup for upgrading dependencies, nun for uninstalling, nci for clean installs, and nd for deduplication.
nci to perform a clean installation (e.g., npm ci or pnpm install --frozen-lockfile).nciUse nup to upgrade your dependencies.
nup: Runs the standard upgrade command.nup -i: Runs an interactive upgrade (Note: not available for npm).nup
nup -iUse ni to install packages. It automatically detects whether to use npm, yarn, pnpm, bun, or deno based on your project's lockfile.
ni: Runs the standard install command (e.g., npm install).ni <package>: Adds a package (e.g., ni vite).ni <package> -D: Adds a package to devDependencies (e.g., ni @types/node -D).ni -P: Installs production dependencies only.ni --frozen: Performs a frozen/clean install (e.g., npm ci).ni -g <package>: Installs a package globally.ni -i: Interactively search and select a package to install.ni vite
ni @types/node -D
ni -P
ni --frozen
ni -iUse nun to remove packages.
nun <package>: Removes a specific package.nun: Interactively multi-select dependencies to remove.nun -g <package>: Removes a package globally.nun webpack
nun
nun -g silentUse nr to execute scripts defined in your package.json using the appropriate package manager.
nr <script>: Runs a specific script (e.g., nr dev --port=3000).nr: Interactively select a script to run.nr -: Reruns the last command.nr -p: Interactively select a package and then a script to run.nd to deduplicate dependencies using the project's package manager (e.g., npm dedupe or pnpm dedupe).ndWhen working in a pnpm workspace with catalogs configured, ni automatically enters catalog mode.
catalog: references into package.json instead of pinned versions.ni will prompt you to select a catalog or skip.-D are respected (e.g., ni typescript -D writes to devDependencies).-w or --workspace to target the workspace root package.json (e.g., ni react -w).To disable catalog mode, set catalog=false in ~/.nirc or use the NI_CATALOG=false environment variable.
ni react -wInstall ni globally using npm to ensure you always use the correct package manager for your project based on its lockfile.
Alternatively, you can install it via Homebrew or asdf.
Use nlx to download and execute a package without installing it globally, similar to npx.
Example: nlx vitest will run vitest using the project's package manager's equivalent of npx or dlx.
nlx vitestYou can customize ni behavior using a .nirc configuration file or environment variables.
defaultAgent: Fallback agent when no lockfile is found (e.g., npm).globalAgent: Agent used for global installs.runAgent: Agent used for running scripts (e.g., node for Node.js 22+).useSfw: Prefix commands with sfw.catalog: Enable/disable catalog mode (default true).NI_CONFIG_FILE: Path to custom configuration file.NI_DEFAULT_AGENT: Sets the default agent.NI_GLOBAL_AGENT: Sets the global agent.NI_USE_SFW: Enables/disables sfw prefix.NI_CATALOG: Enables/disables catalog mode.NI_AUTO_INSTALL: Set to true to automatically install the required package manager globally if missing.; ~/.nirc
defaultAgent=npm
globalAgent=npm
runAgent=node
useSfw=true
catalog=trueni is a CLI tool that simplifies package management by automatically detecting the package manager used in a project (e.g., npm, yarn, pnpm, bun, or deno) and running the appropriate install or add command. Instead of remembering specific flags for different managers, you can use universal ni commands.
ni to run the project's install command.ni <package-name> to add a dependency using the detected package manager.In PowerShell, ni is a built-in alias for New-Item. To use the ni package instead, you must remove the alias.
To remove it for the current session:
'Remove-Item Alias:ni -Force -ErrorAction Ignore'To persist this, add the command to your PowerShell profile script.