Overview
Thepm 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
Add as a dev dependency
Arguments
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: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
Theadd 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