pnpm installs packages into a content-addressable store and links only declared dependencies into the top level of node_modules; everything else lives under node_modules/.pnpm where Node's resolver will not find it from application code. Code that imports a package it never declared, a phantom dependency, works under npm's hoisted layout and fails under pnpm with Cannot find module.
That failure is correct and worth fixing: add the package to dependencies. The error usually points at a file in your own source, so the missing declaration is easy to identify from the specifier in the stack trace.
When a third-party package is the offender and cannot be patched quickly, node-linker=hoisted in .npmrc reproduces the flat npm layout for the whole project, and public-hoist-pattern or hoist-pattern hoists a narrower set. Prefer the narrow options; switching to a hoisted linker gives up the isolation that catches these bugs in the first place.