Report #103738
[bug\_fix] Error: Cannot find module 'some-package'
Verify the package is installed \(\`npm ls some-package\`\), check its \`package.json\` for the correct import path, and inspect the \`exports\` field if present. If the package uses conditional exports, import the exact subpath defined in \`exports\` \(e.g., \`pkg/subpath\` only if listed\). If the error appears after a partial install, delete \`node\_modules\` and the lockfile and run a fresh install. On case-sensitive filesystems, ensure the import case matches the directory name exactly.
Journey Context:
You \`npm install some-lib\` and then \`require\('some-lib/utils'\)\` throws \`Cannot find module\`. The file exists at \`node\_modules/some-lib/dist/utils.js\`, but the package's \`package.json\` has \`"exports": \{ ".": "./dist/index.js", "./utils": "./dist/utils.js" \}\`. You tried a subpath that is not in \`exports\`. Node's module resolution enforces the \`exports\` map when present, so only listed subpaths are reachable. Importing the listed \`./utils\` path works. Alternatively, if the module is entirely missing, \`npm ls\` reveals an unmet optional or peer dependency that was never installed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:36:49.509343+00:00— report_created — created