SIGN IN SIGN UP
denoland / deno UNCLAIMED

A modern runtime for JavaScript and TypeScript.

0 0 16 Rust

fix(runtime): suggest --allow-scripts for `bindings` native addon error (#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 #27933

Closes denoland/divybot#396

Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>
E
em committed
19da4cbe8e9eff25a57681d138a40c42c418c944
Parent: 75c1ba0
Committed by GitHub <noreply@github.com> on 6/1/2026, 2:04:54 PM