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

pm add <packages...> [options]

Options

-D
boolean
default:"false"
Add as a dev dependency

Arguments

packages
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:
pm add "npm install -D typescript"
# Automatically extracts: -D flag and package name
You can paste entire install commands and Better PM will automatically extract the packages and flags.

Examples

Add Production Dependency

pm add express
Output
Running: pnpm add express

Add Development Dependency

pm add -D typescript
Output
Running: pnpm add -D typescript

Add Multiple Packages

pm add react react-dom
Output
Running: pnpm add react react-dom

Add Scoped Package

pm add @types/node -D
Output
Running: pnpm add -D @types/node

Paste Package Manager Commands

# Copy from a README
pm add "npm install --save-dev eslint prettier"
Output
Running: pnpm add -D eslint prettier
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