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

Commit
61 days ago
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>
Author
Parents
Loading