# Cheat Sheet: ni - universal CLI alias for npm/yarn/pnpm/bun

*Tool* `ni` *is a utility that removes the need to recognize a type of package manager in JS projects (npm, yarn, pnpm, bun). It provides a unified interface and uses appropriate commands instead (calls* `yarn` in yarn projects, `npm` in npm projects, etc.*).*

Let's assume getting a project with an unknown manager (at least for the first 5 seconds) or just a situation when we work with multiple projects having different managers. It may become a little bit annoying to pay attention to which manager we need.

The `ni` is a CLI utility that recognizes a project package manager according to its lock file (`yarn.lock`, `package-lock.json`, etc.) and uses appropriate commands. At least basic ones that could be unified.

## Installation

```bash
npm i -g @antfu/ni
```

Also, it is better to create a config `~/.nirc` with default values.

```bash
defaultAgent=npm
globalAgent=npm
```

## Usage

Examples below are based on the `yarn` commands.

```bash
ni      # yarn install
ni X    # yarn add X
ni -D X # yarn add -D X
nr dev  # yarn run dev
na      # yarn
```

A full list is defined at [README.md](https://github.com/antfu-collective/ni) of the library.

It is nothing too special, but it removes a tiny annoying part during app development.
