pm add
Add dependencies to your project
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 namepm add "pnpm add foo bar"
# Extracts: foo and bar as packagespm add "bun add -D @scope/pkg"
# Extracts: -D flag and scoped package nameExamples
Add Production Dependency
pm add express
Running: pnpm add express
Add Development Dependency
pm add -D typescript
Running: pnpm add -D typescript
Add Multiple Packages
pm add react react-dom
Running: pnpm add react react-dom
Add Scoped Package
pm add @types/node -D
Running: pnpm add -D @types/node
Paste Package Manager Commands
# Copy from a README
pm add "npm install --save-dev eslint prettier"
Running: pnpm add -D eslint prettier
How It Works
The add command uses the resolveAddArgs function from src/lib/parse-pm-command.ts to intelligently parse the input:
- Detects common package manager command patterns
- Extracts the
-D(or--save-dev) flag if present - Extracts package names, including scoped packages
- Passes clean arguments to the underlying package manager
Related Commands
- pm remove - Remove dependencies
- pm install - Install dependencies
- pm up - Update dependencies