pnpm clean
别名:purge
安全地从所有工作区项目中移除 node_modules 内容。在 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.
A clean or purge script in package.json overrides the built-in command and receives positional arguments such as dist in pnpm clean dist. pnpm pm clean 和 pnpm pm purge 无论如何都会运行内置命令。
If a custom virtualStoreDir or globalVirtualStoreDir 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.