"Cannot find module" on a package that is clearly installed: the exports map that never heard of your deep import
Problem
A library upgrade from v2 to v3 — with the same files on disk in node_modules/@acme/ui/dist/ — breaks every deep import in the app:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '@acme/ui/dist/components/Button' imported from /app/src/main.tsx
Did you mean to import "@acme/ui/dist/components/Button.js"?The file node_modules/@acme/ui/dist/components/Button.js exists. TypeScript resolves the import fine. Node, at runtime, says the module is not there.
Root cause
v3 added an exports field to package.json — the modern packaging feature that makes a package hide everything except what it explicitly exposes. Once exports exists, any subpath not listed in it stops existing for Node's ESM loader, regardless of what files are on disk. TypeScript's node16/bundler resolution honors exports too, so if the app compiles, the import was going through a looser resolution; the runtime loader is the stricter one and it is the honest one.
The dual-package dimension: exports is also where the import/require conditions live, and a dual-publishing package that lists a subpath only under require produces this same error from ESM consumers — the CJS copy is reachable, the ESM entry for that subpath is not.
{
"name": "@acme/ui",
"type": "module",
… 11 more lines in the fix🔒 the fix — including 3 code blocks — is members-only. $1/mo unlocks everything.