Crates.io | npack |
lib.rs | npack |
version | 0.0.19 |
source | src |
created_at | 2023-12-23 17:29:06.895817 |
updated_at | 2024-03-14 02:32:10.140773 |
description | Use the right package manager |
homepage | https://github.com/zhazhazhu/ni |
repository | https://github.com/zhazhazhu/ni |
max_upload_size | |
id | 1079212 |
size | 119,519 |
ni - use the right package manager
cargo install npack
For bash, zsh and fish shells, there's an automatic installation script.
First ensure that curl and unzip are already installed on you operating system. Then execute:
curl https://ni.zhazhazhu.me/install.sh | bash
ni
- installni
# 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
- runnr 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
nlx
- download & executenlx vitest
# npx vitest
# yarn dlx vitest
# pnpm dlx vitest
# bunx vitest
nu
- upgradenu
# npm upgrade
# yarn upgrade (Yarn 1)
# yarn up (Yarn Berry)
# pnpm update
# bun update
nu -i
# (not available for npm & bun)
# yarn upgrade-interactive (Yarn 1)
# yarn up -i (Yarn Berry)
# pnpm update -i
nun
- uninstallnun webpack
# npm uninstall webpack
# yarn remove webpack
# pnpm remove webpack
# bun remove webpack
nun -g silent
# npm uninstall -g silent
# yarn global remove silent
# pnpm remove -g silent
# bun remove -g silent
nci
- clean installnci
# 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 aliasna
# npm
# yarn
# pnpm
# bun
na run foo
# npm run foo
# yarn run foo
# pnpm run foo
# bun run foo
# ? | Print the command execution depends on the agent
ni vite ?
# -C | Change directory before running the command
ni -C packages/foo vite
nr -C playground dev
# -v, --version | Show version number
ni -v
# -h, --help | Show help
ni -h
; ~/.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"
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.
PowerShell comes with a built-in alias ni
for the New-Item
cmdlet. To remove the alias in your current PowerShell session in favor of this package, use the following command:
'Remove-Item Alias:ni -Force -ErrorAction Ignore'
If you want to persist the changes, you can add them to your PowerShell profile. The profile path is accessible within the $profile
variable. The ps1 profile file can normally be found at
C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
C:\Users\USERNAME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1
C:\Users\USERNAME\Documents\PowerShell\Microsoft.VSCode_profile.ps1
You can use the following script to remove the alias at shell start by adding the above command to your profile:
if (-not (Test-Path $profile)) {
New-Item -ItemType File -Path (Split-Path $profile) -Force -Name (Split-Path $profile -Leaf)
}
$profileEntry = 'Remove-Item Alias:ni -Force -ErrorAction Ignore'
$profileContent = Get-Content $profile
if ($profileContent -notcontains $profileEntry) {
("`n" + $profileEntry) | Out-File $profile -Append -Force -Encoding UTF8
}
nx
and nix
is no longer availableWe renamed nx
/nix
to nlx
to avoid conflicts with the other existing tools - nx and nix. You can always alias them back on your shell configuration file (.zshrc
, .bashrc
, etc).
alias nx="nlx"
# or
alias nix="nlx"