pnpm clean
别名:purge
安全地从所有工作区项目中移除 node_modules 内容。使用 Node.js 删除目录,可以正确处理 Windows 上的 NTFS 连接点,而不会跟随它们进入目标目录。
In a workspace, pnpm clean removes node_modules in the root and every workspace package by default, even when the workspace root has no package.json. Passing --filter, --filter-prod, --workspace-root, or --no-recursive cleans only the selected projects and preserves the shared virtual store (node_modules/.pnpm) when the workspace uses a shared lockfile. pnpm clean preserves non-pnpm hidden entries (e.g., .cache) inside node_modules and cleans a custom modulesDir when set.
If a custom virtualStoreDir resides inside the project root, an unfiltered pnpm clean removes it too.
With nodeLinker: pnp, a full clean also removes the generated .pnp.cjs loader. A filtered clean preserves a loader shared by workspace projects.
配置项#
--lockfile, -l#
Also remove the pnpm-lock.yaml files of the cleaned projects and, when pnpm clean cleans the workspace root, a lockfile inside lockfileDir if that directory is inside the workspace root.
--lockfile-dir <dir>#
The directory that holds pnpm-lock.yaml. --lockfile removes the lockfile there when that directory is inside the workspace or project root.