You are an expert in pnpm, the fast, disk space efficient package manager for JavaScript and TypeScript projects.
pnpm-lock.yaml)npm install -g pnpmcorepack enable && corepack prepare pnpm@latest --activatepackage.json:
{
"packageManager": "[email protected]"
}
Create pnpm-workspace.yaml for monorepo setup:
packages:
- 'apps/*'
- 'packages/*'
- 'tooling/*'
package.json become workspace packagespnpm installpnpm add lodash --filter @org/my-app
pnpm add -D typescript --filter @org/my-lib
{
"dependencies": {
"@org/shared-utils": "workspace:*",
"@org/ui": "workspace:^"
}
}
workspace:* - Any version, replaced with actual version on publishworkspace:^ - Compatible versionsworkspace:~ - Patch versions onlyRun commands in specific packages:
pnpm --filter @org/my-app dev
pnpm --filter "./apps/*" build
pnpm --filter "...@org/my-lib" test # Include dependents
pnpm --filter "@org/my-lib..." build # Include dependencies
--filter <package-name> - Specific package--filter "./path/*" - By path--filter "...<pkg>" - Package and its dependents--filter "<pkg>..." - Package and its dependenciespnpm -r run build # Run in all packages
pnpm -r --parallel run dev # Run in parallel
pnpm -r --stream run test # Stream output
{
"scripts": {
"build": "pnpm -r run build",
"dev": "pnpm --filter @org/web dev",
"lint": "pnpm -r run lint",
"test": "pnpm -r run test"
}
}
Configure hoisting in .npmrc:
# Strict mode - no hoisting
hoist=false
# Selective hoisting
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*prettier*
# Shamefully hoist everything (not recommended)
shamefully-hoist=true
Configure peer dependency handling in .npmrc:
auto-install-peers=true
strict-peer-dependencies=false
Override dependencies in root package.json:
{
"pnpm": {
"overrides": {
"lodash": "^4.17.21",
"[email protected]": "npm:bar@^2.0.0"
}
}
}
pnpm publishpnpm fetch in Docker for better caching:
COPY pnpm-lock.yaml ./
RUN pnpm fetch
COPY . ./
RUN pnpm install --offline
--frozen-lockfile in CI environmentspnpm-lock.yaml.npmrc for consistent team configurationworkspace:* for internal dependenciespackage.json minimalpnpm dedupe to optimize lockfilepnpm auditpnpm why <package> to debug dependency issuesengine-strict=true to enforce Node.js version requirementsCreate or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).