mosaic doctor fails with ERR_PACKAGE_PATH_NOT_EXPORTED fallback miss #383

Closed
opened 2026-04-05 01:37:05 +00:00 by jason.woltje · 0 comments
Owner

mosaic doctor (and all framework-delegated subcommands: init, upgrade, projects, orchestrator-*, etc.) fail on globally-installed CLI with:

[mosaic] Script not found: /home/jarvis/.config/mosaic/tools/_scripts/mosaic-doctor

Root cause

resolveTool() in packages/mosaic/src/commands/launch.ts calls req.resolve('@mosaic/mosaic/package.json') to locate the bundled framework/tools/ directory. The published package.json only exports the . subpath, so Node throws ERR_PACKAGE_PATH_NOT_EXPORTED. The bare catch {} swallows the error silently and falls back to $MOSAIC_HOME/tools/_scripts/…, which does not exist on the user's machine.

Fix

  • Resolve framework dir via fileURLToPath(import.meta.url) (exports-field independent)
  • Add ./package.json and ./framework/* subpath exports (belt-and-suspenders)
  • Bump @mosaic/mosaic 0.0.17 → 0.0.18

Branch: fix/mosaic-doctor-script-resolution

`mosaic doctor` (and all framework-delegated subcommands: init, upgrade, projects, orchestrator-*, etc.) fail on globally-installed CLI with: ``` [mosaic] Script not found: /home/jarvis/.config/mosaic/tools/_scripts/mosaic-doctor ``` ### Root cause `resolveTool()` in `packages/mosaic/src/commands/launch.ts` calls `req.resolve('@mosaic/mosaic/package.json')` to locate the bundled `framework/tools/` directory. The published `package.json` only exports the `.` subpath, so Node throws `ERR_PACKAGE_PATH_NOT_EXPORTED`. The bare `catch {}` swallows the error silently and falls back to `$MOSAIC_HOME/tools/_scripts/…`, which does not exist on the user's machine. ### Fix - Resolve framework dir via `fileURLToPath(import.meta.url)` (exports-field independent) - Add `./package.json` and `./framework/*` subpath exports (belt-and-suspenders) - Bump `@mosaic/mosaic` 0.0.17 → 0.0.18 Branch: `fix/mosaic-doctor-script-resolution`
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#383