{"id":15284311,"url":"https://github.com/zhazhazhu/ni","last_synced_at":"2025-10-18T15:24:12.705Z","repository":{"id":212970062,"uuid":"731716234","full_name":"zhazhazhu/ni","owner":"zhazhazhu","description":"💡  Use the right package manager (Rust)","archived":false,"fork":false,"pushed_at":"2025-05-14T06:42:05.000Z","size":83,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-11T08:13:10.232Z","etag":null,"topics":["antfu","antfu-ni","bun","cli","ni","npack","npm","package-manager","pnpm","rust","yarn"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/npack","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhazhazhu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-14T17:54:03.000Z","updated_at":"2025-06-30T08:58:34.000Z","dependencies_parsed_at":"2024-09-30T14:53:16.299Z","dependency_job_id":"f107e2e8-2a10-4bca-9e22-b67b316eef02","html_url":"https://github.com/zhazhazhu/ni","commit_stats":null,"previous_names":["zhazhazhu/ni"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/zhazhazhu/ni","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhazhazhu%2Fni","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhazhazhu%2Fni/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhazhazhu%2Fni/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhazhazhu%2Fni/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhazhazhu","download_url":"https://codeload.github.com/zhazhazhu/ni/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhazhazhu%2Fni/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278556162,"owners_count":26006081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antfu","antfu-ni","bun","cli","ni","npack","npm","package-manager","pnpm","rust","yarn"],"created_at":"2024-09-30T14:53:13.769Z","updated_at":"2025-10-18T15:24:12.659Z","avatar_url":"https://github.com/zhazhazhu.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ni\n\n**ni** - use the right package manager\n\n#### Rewrite using Rust language, no runtime, no dependencies, can be installed and used, refer to @antfu/ni, specific usage should be consistent with @antfu/ni\n\n### [@antfu/ni](https://github.com/antfu/ni)\n\n# Install\n\n## Using Cargo (Linux/macOS/Windows)\n\n```bash\ncargo install npack\n```\n\n## Using a script (macOS/Linux)\n\nFor bash, zsh and fish shells, there's an automatic installation script.\n\nFirst ensure that curl and unzip are already installed on you operating system. Then execute:\n\n```bash\ncurl https://ni-bz9c.vercel.app/install.sh | bash\n```\n\n\u003ca href='https://docs.npmjs.com/cli/v6/commands/npm'\u003enpm\u003c/a\u003e · \u003ca href='https://yarnpkg.com'\u003eyarn\u003c/a\u003e · \u003ca href='https://pnpm.io/'\u003epnpm\u003c/a\u003e · \u003ca href='https://bun.sh/'\u003ebun\u003c/a\u003e\n\n\u003cbr\u003e\n\n\n### `ni` - install\n\n```bash\nni\n\n# npm install\n# yarn install\n# pnpm install\n# bun install\n```\n\n```bash\nni vite\n\n# npm i vite\n# yarn add vite\n# pnpm add vite\n# bun add vite\n```\n\n```bash\nni @types/node -D\n\n# npm i @types/node -D\n# yarn add @types/node -D\n# pnpm add -D @types/node\n# bun add -d @types/node\n```\n\n```bash\nni --frozen\n\n# npm ci\n# yarn install --frozen-lockfile (Yarn 1)\n# yarn install --immutable (Yarn Berry)\n# pnpm install --frozen-lockfile\n# bun install --no-save\n```\n\n```bash\nni -g eslint\n\n# npm i -g eslint\n# yarn global add eslint (Yarn 1)\n# pnpm add -g eslint\n# bun add -g eslint\n\n# this uses default agent, regardless your current working directory\n```\n\n\u003cbr\u003e\n\n### `nr` - run\n\n```bash\nnr dev --port=3000\n\n# npm run dev -- --port=3000\n# yarn run dev --port=3000\n# pnpm run dev --port=3000\n# bun run dev --port=3000\n```\n\n```bash\nnr\n\n# interactively select the script to run\n# supports https://www.npmjs.com/package/npm-scripts-info convention\n```\n\n```bash\nnr -\n\n# rerun the last command\n```\n\n\u003cbr\u003e\n\n### `nlx` - download \u0026 execute\n\n```bash\nnlx vitest\n\n# npx vitest\n# yarn dlx vitest\n# pnpm dlx vitest\n# bunx vitest\n```\n\n\u003cbr\u003e\n\n### `nu` - upgrade\n\n```bash\nnu\n\n# npm upgrade\n# yarn upgrade (Yarn 1)\n# yarn up (Yarn Berry)\n# pnpm update\n# bun update\n```\n\n```bash\nnu -i\n\n# (not available for npm \u0026 bun)\n# yarn upgrade-interactive (Yarn 1)\n# yarn up -i (Yarn Berry)\n# pnpm update -i\n```\n\n\u003cbr\u003e\n\n### `nun` - uninstall\n\n```bash\nnun webpack\n\n# npm uninstall webpack\n# yarn remove webpack\n# pnpm remove webpack\n# bun remove webpack\n```\n\n```bash\nnun -g silent\n\n# npm uninstall -g silent\n# yarn global remove silent\n# pnpm remove -g silent\n# bun remove -g silent\n```\n\n\u003cbr\u003e\n\n### `nci` - clean install\n\n```bash\nnci\n\n# npm ci\n# yarn install --frozen-lockfile\n# pnpm install --frozen-lockfile\n# bun install --no-save\n```\n\nif the corresponding node manager is not present, this command will install it globally along the way.\n\n\u003cbr\u003e\n\n### `na` - agent alias\n\n```bash\nna\n\n# npm\n# yarn\n# pnpm\n# bun\n```\n\n```bash\nna run foo\n\n# npm run foo\n# yarn run foo\n# pnpm run foo\n# bun run foo\n```\n\n\u003cbr\u003e\n\n### Global Flags\n\n```bash\n# ?               | Print the command execution depends on the agent\nni vite ?\n\n# -C              | Change directory before running the command\nni -C packages/foo vite\nnr -C playground dev\n\n# -v, --version   | Show version number\nni -v\n\n# -h, --help      | Show help\nni -h\n```\n\n\u003cbr\u003e\n\n### Config\n\n```ini\n; ~/.nirc\n\n; fallback when no lock found\ndefaultAgent=npm # default \"prompt\"\n\n; for global installs\nglobalAgent=npm\n```\n\n```bash\n# ~/.bashrc\n\n# custom configuration file path\nexport NI_CONFIG_FILE=\"$HOME/.config/ni/nirc\"\n```\n\n\u003cbr\u003e\n\n### How?\n\n**ni** assumes that you work with lockfiles (and you should)\n\nBefore 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](https://github.com/antfu/ni/blob/main/src/agents.ts).\n\n### Trouble shooting\n\n#### Conflicts with PowerShell\n\nPowerShell 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:\n\n```PowerShell\n'Remove-Item Alias:ni -Force -ErrorAction Ignore'\n```\n\nIf 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\n\n- PowerShell 5 (Windows PowerShell): `C:\\Users\\USERNAME\\Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1`\n- PowerShell 7: `C:\\Users\\USERNAME\\Documents\\PowerShell\\Microsoft.PowerShell_profile.ps1`\n- VSCode: `C:\\Users\\USERNAME\\Documents\\PowerShell\\Microsoft.VSCode_profile.ps1`\n\nYou can use the following script to remove the alias at shell start by adding the above command to your profile:\n\n```PowerShell\nif (-not (Test-Path $profile)) {\n  New-Item -ItemType File -Path (Split-Path $profile) -Force -Name (Split-Path $profile -Leaf)\n}\n\n$profileEntry = 'Remove-Item Alias:ni -Force -ErrorAction Ignore'\n$profileContent = Get-Content $profile\nif ($profileContent -notcontains $profileEntry) {\n  (\"`n\" + $profileEntry) | Out-File $profile -Append -Force -Encoding UTF8\n}\n```\n\n#### `nx` and `nix` is no longer available\n\nWe renamed `nx`/`nix` to `nlx` to avoid conflicts with the other existing tools - [nx](https://nx.dev/) and [nix](https://nixos.org/). You can always alias them back on your shell configuration file (`.zshrc`, `.bashrc`, etc).\n\n```bash\nalias nx=\"nlx\"\n# or\nalias nix=\"nlx\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhazhazhu%2Fni","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhazhazhu%2Fni","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhazhazhu%2Fni/lists"}