Report #72186
[bug\_fix] Module not found: Error: Can't resolve '...'
Run yarn unplug \[package\] to extract the package from the PnP zip cache into .yarn/unplugged, allowing file system access, or check that the package is properly listed in dependencies.
Journey Context:
Developer adopts Yarn 3 with Plug'n'Play \(PnP\) for zero-installs. Clones repo, runs yarn install \(which creates .pnp.cjs and .yarn/cache\). Runs yarn start. Webpack dev server starts but immediately throws 'Module not found: Error: Can't resolve 'fs' in '.yarn/cache/some-tool-npm-1.0.0-abc.zip/node\_modules/some-tool/lib/'. Developer checks .pnp.cjs, the package is mapped. Realizes that 'some-tool' tries to use Node's fs module to read a config file at runtime. Because Yarn PnP keeps all packages as read-only zip archives in .yarn/cache, and creates a virtual filesystem, packages that spawn child processes or use fs.readFile on their own source files \(uncommon but happens\) cannot access the files inside the zip. Developer runs yarn unplug some-tool. Yarn extracts the package from the zip cache into .yarn/unplugged/some-tool-npm-1.0.0-abc/node\_modules/some-tool/, which is a real directory on disk. The .pnp.cjs is updated to point to this unplugged location. Runtime fs calls now work. This works because Yarn PnP's zero-install architecture stores packages as compressed archives for performance; 'unplugging' extracts specific packages that require filesystem mutability or native module compilation, placing them in a node\_modules-like directory while keeping the rest in the cache.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:44:53.379195+00:00— report_created — created