fix(runtime): suggest --allow-scripts for bindings native addon error#34666
Merged
Conversation
When a native addon (e.g. libxmljs) cannot find its compiled `.node` file because npm lifecycle scripts were not run, the widely-used `bindings` npm package throws "Could not locate the bindings file" rather than the Node-style "Cannot find module ... Require stack" error that Deno already recognized. As a result the helpful hint to set up `node_modules` and run `deno install --allow-scripts` was never shown for these packages. Detect the `bindings` package error message as well so the same actionable suggestion is surfaced. Refs #27933 Co-Authored-By: Divy Srivastava <[email protected]>
littledivy
added a commit
to crowlKats/deno
that referenced
this pull request
Jun 10, 2026
…or (denoland#34666) ## Problem Importing an npm package that relies on a native addon (e.g. `npm:libxmljs`, pulled in by `npm:xsd-validator`) fails with: ``` error: Uncaught (in promise) Error: Could not locate the bindings file. Tried: → .../node_modules/libxmljs/build/xmljs.node → .../node_modules/libxmljs/build/Release/xmljs.node ... at bindings (.../node_modules/bindings/bindings.js:96:9) ``` The compiled `.node` file is missing because the npm lifecycle (build) scripts were not run. Deno already detects this situation and prints an actionable hint ("…run `deno install --allow-scripts` to setup `node_modules`"), but only for the Node-style `Cannot find module '…/build/Release/xxx.node'` / `Require stack:` error. The extremely common [`bindings`](https://www.npmjs.com/package/bindings) npm package (used by libxmljs and many other native addons) throws a *different* message — `Could not locate the bindings file. Tried: …` — so the helpful suggestion was never shown, leaving users stuck. ## Fix Extend the native-addon error detection in `get_suggestions_for_terminal_errors` to also match the `bindings` package error message, so the same `--allow-scripts` / `nodeModulesDir` hint is surfaced. ## Test Added a spec test (`tests/specs/run/node_addon_bindings_suggestion`) that reproduces the `bindings` error message and asserts the suggestion is emitted. Closes denoland#27933 Closes denoland/divybot#396 Co-authored-by: divybot <[email protected]> Co-authored-by: Divy Srivastava <[email protected]>
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.
Problem
Importing an npm package that relies on a native addon (e.g.
npm:libxmljs, pulled in bynpm:xsd-validator) fails with:The compiled
.nodefile is missing because the npm lifecycle (build) scripts were not run. Deno already detects this situation and prints an actionable hint ("…rundeno install --allow-scriptsto setupnode_modules"), but only for the Node-styleCannot find module '…/build/Release/xxx.node'/Require stack:error.The extremely common
bindingsnpm package (used by libxmljs and many other native addons) throws a different message —Could not locate the bindings file. Tried: …— so the helpful suggestion was never shown, leaving users stuck.Fix
Extend the native-addon error detection in
get_suggestions_for_terminal_errorsto also match thebindingspackage error message, so the same--allow-scripts/nodeModulesDirhint is surfaced.Test
Added a spec test (
tests/specs/run/node_addon_bindings_suggestion) that reproduces thebindingserror message and asserts the suggestion is emitted.Closes #27933
Closes denoland/divybot#396