Skip to content
Better PM
Esc
↑↓navigate↵open⌘Jpreview

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 name
pm add "pnpm add foo bar"
# Extracts: foo and bar as packages
pm add "bun add -D @scope/pkg"
# Extracts: -D flag and scoped package name

Examples

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:

  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

Was this page helpful?