Skip to main content

Overview

The pm add command adds dependencies to your project. It supports paste-friendly syntax that automatically extracts package names and flags from common package manager commands.

Syntax

Options

boolean
default:"false"
Add as a dev dependency

Arguments

string[]
required
One or more package names to install. Supports paste-friendly syntax.

Paste-Friendly Syntax

Better PM intelligently parses common package manager commands, allowing you to paste commands directly from READMEs:
You can paste entire install commands and Better PM will automatically extract the packages and flags.

Examples

Add Production Dependency

Output

Add Development Dependency

Output

Add Multiple Packages

Output

Add Scoped Package

Output

Paste Package Manager Commands

Output
Better PM automatically detects your project’s package manager (pnpm, bun, or npm) and uses the appropriate command.

How It Works

The add command uses the resolveAddArgs function from src/lib/parse-pm-command.ts to intelligently parse the input:
  1. Detects common package manager command patterns
  2. Extracts the -D (or --save-dev) flag if present
  3. Extracts package names, including scoped packages
  4. Passes clean arguments to the underlying package manager