Report #17235
[bug\_fix] Required unplugged package not found / cannot find module \(from .pnp.cjs\) when loading native addons
Add the package to the unplugged list in .yarnrc.yml: dependenciesMeta..unplugged: true, then run yarn install again. This extracts the package from the zip archive to a physical node\_modules/.yarn/unplugged directory so that Node.js can load the native .node binary via dlopen.
Journey Context:
Developer migrates a project to Yarn 3 with Plug'n'Play \(PnP\) to eliminate node\_modules bloat. Standard JavaScript packages work flawlessly with the .pnp.cjs loader. However, when they add a dependency on sharp \(image processing\) or bcrypt \(password hashing\), the application crashes at runtime with 'cannot find module' errors pointing to paths inside .yarn/cache \(zip files\). The developer realizes that native Node.js addons \(.node files\) cannot be dynamically loaded via require\(\) from within zip archives; they must exist as real files on the filesystem. They consult the Yarn documentation and create a .yarnrc.yml configuration file, adding an entry under dependenciesMeta to mark the specific package as 'unplugged'. After running yarn install again, they observe that Yarn has extracted the package to .yarn/unplugged and created the necessary symlinks in node\_modules. The application now successfully loads the native addon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:49:44.317320+00:00— report_created — created