Skip to main content
Version: 11.x

pnpm clean

别名:purge

🌐 Aliases: purge

安全地从所有工作区项目中移除 node_modules 内容。使用 Node.js 来删除目录,这在 Windows 上可以正确处理 NTFS 连接点,而不会访问它们的目标。

🌐 Safely remove node_modules contents from all workspace projects. Uses Node.js to remove directories, which correctly handles NTFS junctions on Windows without following them into their targets.

在工作区中,node_modules 目录会在根目录和每个工作区包中被清理。node_modules 内的非 pnpm 隐藏条目(例如 .cache)将被保留。

🌐 In a workspace, node_modules directories are cleaned in the root and every workspace package. Non-pnpm hidden entries (e.g., .cache) inside node_modules are preserved.

如果配置了自定义 virtualStoreDir 并且它位于项目根目录内(但在 node_modules 之外),它也会被移除。

🌐 If a custom virtualStoreDir is configured and it resides inside the project root (but outside node_modules), it is also removed.

选项

🌐 Options

--lockfile, -l

还要删除 pnpm-lock.yaml 文件。

🌐 Also remove pnpm-lock.yaml files.