Report #9124
[bug\_fix] Error: Cannot find module '.pnp.cjs' / MODULE\_NOT\_FOUND in Yarn PnP
Run yarn install to generate the .pnp.cjs file and populate .yarn/cache, or configure nodeLinker: node-modules in .yarnrc.yml to disable PnP. Root cause: Yarn Plug'n'Play \(PnP\) replaces node\_modules with a single .pnp.cjs loader file; if this file is missing \(not committed in zero-installs\) or the cache is unplugged, Node cannot resolve any packages.
Journey Context:
A developer clones a repository using Yarn 3 with Plug'n'Play \(zero-installs\). The repository documentation mentions that .yarn/cache is committed to git. However, the developer accidentally deleted the .pnp.cjs file while cleaning up untracked files. Running any yarn command or node -r ./.pnp.cjs ./src/index.js fails with 'Cannot find module .pnp.cjs'. The developer runs yarn install, which regenerates the .pnp.cjs loader file and verifies the cache integrity. Alternatively, for a project not using zero-installs, missing .yarn/cache would require unplugging packages or switching to nodeLinker: node-modules.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:19:38.805618+00:00— report_created — created