0.18.0 • Published 1 month ago

@antfu/ni v0.18.0

Weekly downloads
1,326
License
MIT
Repository
github
Last release
1 month ago

ni

npm i in a yarn project, again? F**k!

ni - use the right package manager

npm · yarn · pnpm · bun

ni - install

ni

# npm install
# yarn install
# pnpm install
# bun install
ni vite

# npm i vite
# yarn add vite
# pnpm add vite
# bun add vite
ni @types/node -D

# npm i @types/node -D
# yarn add @types/node -D
# pnpm add -D @types/node
# bun add -d @types/node
ni --frozen

# npm ci
# yarn install --frozen-lockfile (Yarn 1)
# yarn install --immutable (Yarn Berry)
# pnpm install --frozen-lockfile
# bun install --no-save
ni -g eslint

# npm i -g eslint
# yarn global add eslint (Yarn 1)
# pnpm add -g eslint
# bun add -g eslint

# this uses default agent, regardless your current working directory

nr - run

nr dev --port=3000

# npm run dev -- --port=3000
# yarn run dev --port=3000
# pnpm run dev -- --port=3000
# bun run dev --port=3000
nr

# interactively select the script to run
# supports https://www.npmjs.com/package/npm-scripts-info convention
nr -

# rerun the last command

nx - execute

nx vitest

# (not available for bun)
# npx vitest
# yarn dlx vitest
# pnpm dlx vitest

nu - upgrade

nu

# (not available for bun)
# npm upgrade
# yarn upgrade (Yarn 1)
# yarn up (Yarn Berry)
# pnpm update
nu -i

# (not available for npm & bun)
# yarn upgrade-interactive (Yarn 1)
# yarn up -i (Yarn Berry)
# pnpm update -i

nun - uninstall

nun webpack

# npm uninstall webpack
# yarn remove webpack
# pnpm remove webpack
# bun remove webpack
nun -g eslint

# npm uninstall -g eslint
# yarn global remove eslint
# pnpm remove -g eslint
# bun remove -g eslint

nci - clean install

nci

# npm ci
# yarn install --frozen-lockfile
# pnpm install --frozen-lockfile
# bun install --no-save

if the corresponding node manager is not present, this command will install it globally along the way.

na - agent alias

na

# npm
# yarn
# pnpm
# bun
na run foo

# npm run foo
# yarn run foo
# pnpm run foo
# bun run foo

Change Directory

ni -C packages/foo vite
nr -C playground dev

Config

; ~/.nirc

; fallback when no lock found
defaultAgent=npm # default "prompt"

; for global installs
globalAgent=npm
# ~/.bashrc

# custom configuration file path
export NI_CONFIG_FILE="$HOME/.config/ni/nirc"

How?

ni assumes that you work with lockfiles (and you should)

Before it runs, it will detect your yarn.lock / pnpm-lock.yaml / package-lock.json / bun.lockb to know current package manager (or packageManager field in your packages.json if specified), and runs the corresponding commands.

Trouble shooting

Conflicts with PowerShell on Windows

PowerShell come with a built-in alias ni for New Item. To remove the alias in favor of this package:

Create or edit file C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1, adding following line:

Remove-Item Alias:ni -Force -ErrorAction Ignore

Create or edit file C:\Program Files\PowerShell\7\Microsoft.PowerShell_profile.ps1, adding following line:

Remove-Alias -Name ni -Force
0.18.0

1 month ago

0.17.2

3 months ago

0.17.0

3 months ago

0.17.1

3 months ago

0.16.3

3 months ago

0.15.0

5 months ago

0.16.1

5 months ago

0.16.2

5 months ago

0.14.0

6 months ago

0.12.0

10 months ago

0.11.1

10 months ago

0.13.0

8 months ago

0.13.1

7 months ago

0.13.2

7 months ago

0.11.0

10 months ago

0.10.2

11 months ago

0.10.1

11 months ago

0.10.0

12 months ago

0.9.3

1 year ago

0.9.0

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.9.2

1 year ago

0.5.9

1 year ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.8

1 year ago

0.5.7

1 year ago

0.5.6

1 year ago

0.5.5

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.1

2 years ago