Chuyển đến nội dung
Skillpedia
Lập trình chung6.0k · #14443

pnpm

Skill này làm gì

Skill này giải thích cách cài đặt và quản lý thư viện code bằng pnpm, một công cụ nhanh dùng trong dự án JavaScript. Skill dành cho lập trình viên muốn cài đặt nhanh, đáng tin cậy và các dự án nhiều gói gọn gàng.

Khi nào nên dùng

  • ✓Khi bạn cần cài hoặc cập nhật phụ thuộc trong một dự án JavaScript dùng pnpm.
  • ✓Khi bạn thiết lập một workspace có nhiều gói trong cùng một repository.
  • ✓Khi bạn muốn cài đặt đáng tin cậy trong một hệ thống build tự động.

Liên kết skill

https://github.com/antfu/skills/blob/main/skills/pnpm/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/antfu/skills/blob/main/skills/pnpm/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập pnpm cho dự án của tôi với một workspace cho ba gói và cài đặt đáng tin cậy trên CI.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent làm theo hướng dẫn của pnpm về lệnh và cấu hình, giữ cài đặt dự án trong file workspace, và dùng cài đặt khóa phiên bản trong các hệ thống build tự động.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

pnpm is a fast, disk space efficient package manager. It uses a content-addressable store to deduplicate packages across all projects on a machine, and enforces strict dependency resolution by default, preventing phantom dependencies.

pnpm v12 is a Rust rewrite of v11: stable, and keeps v11's commands, flags, settings, and lockfile format — so most guidance here applies to both. A handful of v12 behaviors differ (git deps resolve via HTTPS, project-aware global bins, other package managers, packageImportMethod: auto hardlinks first on Linux, --resolution-only removed) — see best-practices-migration.

Configuration model (important): pnpm settings live in pnpm-workspace.yaml (and the global config.yaml) using camelCase keys. .npmrc is used only for authentication/registry credentials, and the pnpm field of package.json is no longer read. When working in a pnpm project, check pnpm-workspace.yaml for settings/workspace structure and .npmrc only for auth. Always use --frozen-lockfile (or pnpm ci) in CI.

The skill is based on pnpm 12.x, generated at 2026-09-25. It covers v11+v12 behavior (config split, isolated global packages, allowBuilds, pmOnFail, global virtual store, native release management, workspace task orchestration, and experimental Python/Cargo support) where current docs describe them.

Core

Topic Description Reference
CLI Commands install/add/remove/update, run, dlx/pnx, workspace, runtime, publishing (version, view, sbom, stage) core-cli
Configuration pnpm-workspace.yaml settings (camelCase), global config.yaml, packageConfigs, .npmrc auth core-config
Workspaces Monorepo support: filtering, workspace protocol, shared lockfile, packageConfigs core-workspaces
Store Content-addressable store, virtual store, node linker modes, frozen/read-only store core-store

Features

Topic Description Reference
Catalogs Centralized dependency versions; catalogMode, catalog: in overrides features-catalogs
Overrides Force versions (incl. transitive & peer deps); packageExtensions features-overrides
Patches Modify third-party packages; patchedDependencies in pnpm-workspace.yaml features-patches
Aliases Install under custom names (npm:) and registry aliases (namedRegistries) features-aliases
Hooks .pnpmfile.mjs hooks (readPackage, updateConfig, beforePacking), finders, resolvers/fetchers features-hooks
Peer Dependencies Auto-install, strict mode, rules, dedupePeers, peers check features-peer-deps
Config Dependencies Share hooks/settings/catalogs/patches across repos via configDependencies features-config-dependencies
Global Virtual Store & Shims Shared node_modules, git-worktree multi-agent setups, isolated global packages, project-aware bins, other package managers features-global-virtual-store
Supply-Chain Security Build approval (allowBuilds), minimumReleaseAge, trustPolicy, lockfile integrity features-supply-chain-security
Task Orchestration Cross-project task graphs (tasks/dependsOn), concurrency groups, priority, pnpm pipeline features-task-orchestration
Release Management Native versioning: pnpm change/version -r/lane, lanes, epics, fixed groups features-versioning
Multi-Ecosystem Python (pypi:) and Cargo (crate:) dependencies alongside npm (experimental) features-multi-ecosystem

Best Practices

Topic Description Reference
CI/CD Setup GitHub Actions, GitLab, Docker, pnpm ci, store caching, frozen lockfiles best-practices-ci
Migration npm/Yarn → pnpm, phantom deps, and pnpm v10 → v11 → v12 upgrade notes best-practices-migration
Performance
Câu hỏi thường gặp

Cài đặt pnpm được lưu ở đâu?

Cài đặt dự án nằm trong file workspace, còn file cấu hình chủ yếu dùng cho thông tin đăng nhập.

Vì sao dùng pnpm thay vì npm?

pnpm tiết kiệm dung lượng đĩa bằng cách chia sẻ gói giữa các dự án và kiểm tra phụ thuộc chặt chẽ.

Skill có bao quát monorepo không?

Có. Skill bao quát workspace, nơi chứa nhiều gói trong cùng một repository.

Chi tiết

Mô tả gốc của tác giả

Node.js package manager with strict dependency resolution. Use when running pnpm specific commands, configuring workspaces via pnpm-workspace.yaml, or managing dependencies with catalogs, patches, overrides, config dependencies, or the global virtual store.

repo: antfu/skills

Độ phổ biến

Sao GitHub
6.0k
Vị trí xếp hạng
#14443
Giấy phép
MIT
Cập nhật
30/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự