Skip to content

fix: lazy-install JS parser npm deps on first use#39

Merged
joshbouncesecurity merged 1 commit intomasterfrom
fix/js-parser-auto-npm-install
Apr 19, 2026
Merged

fix: lazy-install JS parser npm deps on first use#39
joshbouncesecurity merged 1 commit intomasterfrom
fix/js-parser-auto-npm-install

Conversation

@joshbouncesecurity
Copy link
Copy Markdown
Owner

Summary

  • openant parse on a JS/TS repo fails with Cannot find module 'ts-morph' when the JS parser's node_modules/ hasn't been populated. There's no installer step that runs npm install for libs/openant-core/parsers/javascript/ — CI runs it, docs mention it, but a user who builds the Go CLI and runs openant parse hits an opaque failure.
  • _parse_javascript now checks for parsers/javascript/node_modules/ before invoking Node and runs npm install once if it's missing. Mirrors the Go CLI's venv bootstrap in apps/openant-cli/internal/python/runtime.go, but scoped to actual JS parser use so Python/Go-only users never need npm.
  • Fails fast with a clear error if npm is not on PATH or npm install fails.

Test plan

  • Unit tests in tests/test_js_parser_bootstrap.py — 5 cases:
    • skips install when node_modules/ exists
    • runs npm install in the parser dir when missing
    • raises a clear RuntimeError when npm is not on PATH
    • raises when npm install exits non-zero
    • _parse_javascript aborts before running Node if bootstrap fails
  • Existing tests/test_parser_adapter.py + tests/test_js_parser.py still pass (26 total).
  • CI green on Linux/macOS/Windows.

🤖 Generated with Claude Code

openant parse fails with "Cannot find module 'ts-morph'" when the JS parser's
node_modules directory hasn't been populated — there's no bootstrap step that
runs npm install the way the Go CLI's runtime.go does for the Python venv.

_parse_javascript now checks for parsers/javascript/node_modules/ before
invoking Node, and shells out to npm install once if it's missing. Matches
the venv's "first run installs, later runs are fast" UX, but scoped to
actual JS parser use so Python/Go-only users don't need npm.

Fails with a clear error if npm is not on PATH or install fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joshbouncesecurity joshbouncesecurity merged commit 379dad6 into master Apr 19, 2026
7 checks passed
@joshbouncesecurity joshbouncesecurity deleted the fix/js-parser-auto-npm-install branch April 19, 2026 15:08
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.

1 participant