pnpm clean
Aliases: purge
Safely remove node_modules contents from all workspace projects. Removes directories without following NTFS junctions on Windows into their targets.
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 and pnpm pm purge run the built-in command regardless.
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.
Opzioni#
--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.