fix: lazy-install JS parser npm deps on first use#39
Merged
joshbouncesecurity merged 1 commit intomasterfrom Apr 19, 2026
Merged
fix: lazy-install JS parser npm deps on first use#39joshbouncesecurity merged 1 commit intomasterfrom
joshbouncesecurity merged 1 commit intomasterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openant parseon a JS/TS repo fails withCannot find module 'ts-morph'when the JS parser'snode_modules/hasn't been populated. There's no installer step that runsnpm installforlibs/openant-core/parsers/javascript/— CI runs it, docs mention it, but a user who builds the Go CLI and runsopenant parsehits an opaque failure._parse_javascriptnow checks forparsers/javascript/node_modules/before invoking Node and runsnpm installonce if it's missing. Mirrors the Go CLI's venv bootstrap inapps/openant-cli/internal/python/runtime.go, but scoped to actual JS parser use so Python/Go-only users never need npm.npmis not onPATHornpm installfails.Test plan
tests/test_js_parser_bootstrap.py— 5 cases:node_modules/existsnpm installin the parser dir when missingRuntimeErrorwhennpmis not on PATHnpm installexits non-zero_parse_javascriptaborts before running Node if bootstrap failstests/test_parser_adapter.py+tests/test_js_parser.pystill pass (26 total).🤖 Generated with Claude Code