unjs/nypm

🌈 Unified Package Manager for Node.js (npm, pnpm, yarn), Bun, Deno, Nub, Aube.

708

stars

285

commits

TypeScript

primary language

Sep 8, 2026

updated

Browse cluster: Vue.js state management and SSR β†’

README

🌈 nypm

npm version npm downloads codecov

🌈 Unified Package Manager for Node.js (npm, pnpm, yarn), Bun and Deno.

βœ… Supports npm, yarn, pnpm, bun, deno, aube and nub out of the box with a unified API.

βœ… Provides an API interface to interact with package managers.

βœ… Autodetects project's package manager using package.json and known lockfiles.

βœ… corepack integration for pnpm and yarn.

nypm command

Install dependencies:

npx nypm i

Add a dependency:

npx nypm add defu

Remove a dependency:

npx nypm remove defu

API Usage

Install package:

# ✨ Auto-detect
npx nypm install nypm

Import:

// ESM import
import { addDependency } from "nypm";

// or dynamic import
const { addDependency } = await import("nypm");

addDependency(name, options)

Adds dependency to the project.

addDevDependency(name, options)

Adds dev dependency to the project.

detectPackageManager(cwd, options)

Detect the package manager used in a directory (and up) by checking various sources:

  1. Use packageManager field from package.json
  2. Use devEngines.packageManager field from package.json
  3. Known lock files and other files

ensureDependencyInstalled(name, options)

Ensures dependency is installed.

installDependencies(options)

Installs project dependencies.

removeDependency(name, options)

Removes dependency from the project.

dedupeDependencies(options)

Dedupe project dependencies.

[!NOTE] For bun and deno it will remove the lockfile and reinstall all dependencies.

runScript(name, options)

Runs a script defined in the package.json file.

dlx(package, options)

Download and execute a package with the package manager.

installDependenciesCommand(<pm>, { short?, frozenLockFile? })

Get the command to install dependencies with the package manager.

addDependencyCommand(<pm>, <name>, { dev?, global?, workspace?, yarnBerry?, short? })

Get the command to add a dependency with the package manager.

runScriptCommand(<pm>, <name>, { args? })

Get the command to run a script with the package manager.

dlxCommand(<pm>, <name>, { args?, short?, packages? })

Get the command to download and execute a package with the package manager.

πŸ’» Development

  • Clone this repository
  • Play Nyan Cat in the background (really important!)
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

NYPM is inspired from previous attempts and projects for unifying package manager experience.

License

Made with πŸ’›

Published under MIT License.

Contributors

(top 30 of 31)

pi0

145 commits

renovate[bot]

88 commits

DamianGlowala

8 commits

danielroe

7 commits

unjs/nypm

🌈 Unified Package Manager for Node.js (npm, pnpm, yarn), Bun, Deno, Nub, Aube.

708

stars

285

commits

TypeScript

primary language

Sep 8, 2026

updated

Browse cluster: Vue.js state management and SSR β†’

README

🌈 nypm

npm version npm downloads codecov

🌈 Unified Package Manager for Node.js (npm, pnpm, yarn), Bun and Deno.

βœ… Supports npm, yarn, pnpm, bun, deno, aube and nub out of the box with a unified API.

βœ… Provides an API interface to interact with package managers.

βœ… Autodetects project's package manager using package.json and known lockfiles.

βœ… corepack integration for pnpm and yarn.

nypm command

Install dependencies:

npx nypm i

Add a dependency:

npx nypm add defu

Remove a dependency:

npx nypm remove defu

API Usage

Install package:

# ✨ Auto-detect
npx nypm install nypm

Import:

// ESM import
import { addDependency } from "nypm";

// or dynamic import
const { addDependency } = await import("nypm");

addDependency(name, options)

Adds dependency to the project.

addDevDependency(name, options)

Adds dev dependency to the project.

detectPackageManager(cwd, options)

Detect the package manager used in a directory (and up) by checking various sources:

  1. Use packageManager field from package.json
  2. Use devEngines.packageManager field from package.json
  3. Known lock files and other files

ensureDependencyInstalled(name, options)

Ensures dependency is installed.

installDependencies(options)

Installs project dependencies.

removeDependency(name, options)

Removes dependency from the project.

dedupeDependencies(options)

Dedupe project dependencies.

[!NOTE] For bun and deno it will remove the lockfile and reinstall all dependencies.

runScript(name, options)

Runs a script defined in the package.json file.

dlx(package, options)

Download and execute a package with the package manager.

installDependenciesCommand(<pm>, { short?, frozenLockFile? })

Get the command to install dependencies with the package manager.

addDependencyCommand(<pm>, <name>, { dev?, global?, workspace?, yarnBerry?, short? })

Get the command to add a dependency with the package manager.

runScriptCommand(<pm>, <name>, { args? })

Get the command to run a script with the package manager.

dlxCommand(<pm>, <name>, { args?, short?, packages? })

Get the command to download and execute a package with the package manager.

πŸ’» Development

  • Clone this repository
  • Play Nyan Cat in the background (really important!)
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

NYPM is inspired from previous attempts and projects for unifying package manager experience.

License

Made with πŸ’›

Published under MIT License.

Contributors

(top 30 of 31)

pi0

145 commits

renovate[bot]

88 commits

DamianGlowala

8 commits

danielroe

7 commits

Languages

TypeScript

94.5%

JavaScript

5.5%