Skip to content

fix: add @clack/prompts transitive deps to fix npx installation#136

Merged
colbymchenry merged 2 commits into
colbymchenry:mainfrom
mfrancime:fix/npx-clack-transitive-deps
May 8, 2026
Merged

fix: add @clack/prompts transitive deps to fix npx installation#136
colbymchenry merged 2 commits into
colbymchenry:mainfrom
mfrancime:fix/npx-clack-transitive-deps

Conversation

@mfrancime

Copy link
Copy Markdown
Contributor

Summary

  • Adds fast-wrap-ansi, fast-string-width, and sisteransi as direct dependencies

Problem

When installed via npx, npm's flat node_modules cache fails to hoist ESM-only transitive dependencies from @clack/prompts@clack/core. This causes:

Cannot find package '/root/.npm/_npx/.../node_modules/fast-wrap-ansi/index.js'
imported from /root/.npm/_npx/.../node_modules/@clack/core/dist/index.mjs

Reproduces on: Node 24.11.0 + npm 11.6.1 with npx @colbymchenry/codegraph@0.7.3

Root cause

@clack/core@1.2.0 imports fast-wrap-ansi (ESM-only, no exports map, just "main": "lib/main.js"). In a normal npm install, dependency hoisting puts fast-wrap-ansi in the top-level node_modules/. But in an npx cache directory, the flat structure sometimes fails to resolve these transitive ESM deps, causing a Cannot find package error at runtime.

Fix

Promote the three transitive dependencies (fast-wrap-ansi, fast-string-width, sisteransi) to direct dependencies in package.json. This guarantees they're always installed at the top level regardless of installation method. These are already required at runtime — this just makes the dependency explicit.

Test plan

  • npx @colbymchenry/codegraph --help works on Node 24 after clearing ~/.npm/_npx
  • npm install -g @colbymchenry/codegraph still works
  • Interactive installer launches without import errors

🤖 Generated with Claude Code

When installed via `npx`, npm's flat node_modules cache fails to
hoist ESM-only transitive dependencies from @clack/prompts → @clack/core.
This causes:

  Cannot find package 'fast-wrap-ansi/index.js' imported from
  @clack/core/dist/index.mjs

Adding fast-wrap-ansi, fast-string-width, and sisteransi as direct
dependencies ensures they are resolved correctly in all installation
contexts (npx, global, local).

Reproduces on Node 24 + npm 11 with `npx @colbymchenry/codegraph@0.7.3`.
@clack/prompts@1.3.0 shipped with major bumps to its transitive deps
(fast-wrap-ansi 0.1 → 0.2, fast-string-width 1 → 3). Promoting them
at the older pins would have caused npm to install both sets side by
side, defeating the dedup goal of this fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@colbymchenry

Copy link
Copy Markdown
Owner

Thanks for the diagnosis — verified the npm hoisting issue is real and the transitive-deps were exactly as you identified.

Pushed a follow-up commit to your branch bumping the pins to match @clack/prompts@1.3.0 (which shipped after this PR was opened and changed the transitive versions to fast-wrap-ansi@^0.2.0 and fast-string-width@^3.0.2). Merging now.

@colbymchenry colbymchenry merged commit 38d1556 into colbymchenry:main May 8, 2026
jorgerobles pushed a commit to jorgerobles/codegraph that referenced this pull request Jun 1, 2026
…ymchenry#136)

* fix: add @clack/prompts transitive deps to fix npx installation

When installed via `npx`, npm's flat node_modules cache fails to
hoist ESM-only transitive dependencies from @clack/prompts → @clack/core.
This causes:

  Cannot find package 'fast-wrap-ansi/index.js' imported from
  @clack/core/dist/index.mjs

Adding fast-wrap-ansi, fast-string-width, and sisteransi as direct
dependencies ensures they are resolved correctly in all installation
contexts (npx, global, local).

Reproduces on Node 24 + npm 11 with `npx @colbymchenry/codegraph@0.7.3`.

* chore: bump @clack/prompts to 1.3.0 with matching transitive pins

@clack/prompts@1.3.0 shipped with major bumps to its transitive deps
(fast-wrap-ansi 0.1 → 0.2, fast-string-width 1 → 3). Promoting them
at the older pins would have caused npm to install both sets side by
side, defeating the dedup goal of this fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: mfrancime <mfrancime@users.noreply.github.com>
Co-authored-by: Colby McHenry <me@colbymchenry.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants