thedotmack/claude-mem · error

Post-install check failed: unresolvable modules: ${unresolva

Error message

Post-install check failed: unresolvable modules: ${unresolvable.join(', ')}

What it means

Thrown by verifyCriticalModules() when one or more declared dependencies cannot be resolved from node_modules, or when the required zod subpath exports ('zod/v3','zod/v4','zod/v4-mini') fail to resolve. The check exists because a stale/partial install can leave package directories present while their importable entry points or subpath exports are broken — which would later surface as a runtime 'Cannot find module'. It fails loud at install time instead.

Source

Thrown at src/npx-cli/install/setup-runtime.ts:296

  }

  // zod ships its public API behind subpath exports the worker bundle requires.
  // The package dir existing does NOT imply these subpaths resolve (#2730).
  if (dependencies.includes('zod')) {
    for (const subpath of ZOD_REQUIRED_SUBPATHS) {
      try {
        requireFromTarget.resolve(subpath, { paths: resolvePaths });
      } catch {
        // [ANTI-PATTERN IGNORED]: subpath resolve failure is the condition being
        // probed; it is collected in `unresolvable` and surfaced as a loud
        // install failure below.
        unresolvable.push(subpath);
      }
    }
  }

  if (unresolvable.length > 0) {
    throw new Error(
      `Post-install check failed: unresolvable modules: ${unresolvable.join(', ')}`,
    );
  }
}

/** Build an ephemeral summary so callers (e.g. repair) may omit it. */
function summaryOrEphemeral(summary?: InstallSummary): InstallSummary {
  return summary ?? { warnings: [], failedIDEs: [] };
}

export async function ensureBun(summary?: InstallSummary): Promise<{ bunPath: string; version: string }> {
  const sum = summaryOrEphemeral(summary);
  if (!isBunInstalled()) {
    // installBun throws a platform-specific Error on failure; route it through
    // the central decision point so it becomes a loud ABORT (bun is mandatory
    // for hooks — there is no opt-out).
    try {
      installBun();

View on GitHub (pinned to d768ba3643)

Solutions

  1. Delete node_modules and the lockfile cache, then run a clean `bun install` (or the project's install command) and retry.
  2. If a zod subpath is listed, confirm the installed zod version ships that subpath export; pin/upgrade zod if not.
  3. If a bin-only dependency is flagged, ensure both its bare name and its package.json fail to resolve — if only the bare name fails, that path may need fixing in the resolver, but the fallback to <dep>/package.json already handles true bin-only packages.
  4. Verify the target dir passed to verifyCriticalModules is the one whose node_modules you just installed into.

Example fix

# before — partial node_modules
# (verifyCriticalModules throws on missing zod/v3)
# after — clean reinstall
rm -rf node_modules && bun install
Defensive patterns

Strategy: validation

Validate before calling

import { createRequire } from 'module';
import { existsSync } from 'fs';
const req = createRequire(join(targetDir, 'node_modules', 'noop.js'));
for (const sub of ['zod/v3','zod/v4','zod/v4-mini']) {
  try { req.resolve(sub, { paths: [join(targetDir,'node_modules')] }); }
  catch { throw new Error(`Run a clean install: cannot resolve ${sub}`); }
}

Type guard

function allResolve(targetDir: string, deps: string[]): boolean {
  const req = createRequire(join(targetDir, 'node_modules', 'noop.js'));
  return deps.every(d => { try { req.resolve(d, { paths: [join(targetDir,'node_modules')] }); return true; } catch { return false; } });
}

Try / catch

try {
  verifyCriticalModules(targetDir);
} catch (e) {
  if (e instanceof Error && /unresolvable modules/.test(e.message)) {
    // wipe node_modules and run a clean install, then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: An interrupted/partial `bun install` left node_modules incomplete. A package's exports map changed (or a pinned version lacks the subpath) so zod/v3 etc. no longer resolve. A corrupted node_modules where the dir exists but the entry file is missing. A dependency that is bin-only AND whose package.json itself is unresolvable (both resolves fail).

Common situations: Switching node_modules between package managers (npm/pnpm/bun) without a clean reinstall. A lockfile drift where installed versions don't match. A node_modules restored from a broken cache. Renamed/moved deps after a branch switch without reinstalling.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12). Data as JSON: /api/errors/f61b69bfdf9558b2. Report an issue: GitHub.