Skip to content

fix(runtime): suggest --allow-scripts for bindings native addon error#34666

Merged
littledivy merged 1 commit into
mainfrom
orch/divybot-396
Jun 1, 2026
Merged

fix(runtime): suggest --allow-scripts for bindings native addon error#34666
littledivy merged 1 commit into
mainfrom
orch/divybot-396

Conversation

@divybot

@divybot divybot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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 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 #27933

Closes denoland/divybot#396

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
littledivy merged commit 19da4cb into main Jun 1, 2026
137 checks passed
@littledivy
littledivy deleted the orch/divybot-396 branch June 1, 2026 14:04
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]>
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.

binding problem with libxmljs

2 participants