background-agents icon indicating copy to clipboard operation
background-agents copied to clipboard

Sharp's node-gyp & node-addon-api dependencies

Open kadams54 opened this issue 7 months ago • 3 comments

  • node: 24.7.0 (via asdf)
  • npm: 11.5.1 (via asdf)
  • macOS: 26.4.1

When I try to run npm install on a fresh clone/fork of the repo, I get the following error:

❯ npm install
npm warn deprecated [email protected]: Use your platform's native DOMException instead
npm warn deprecated [email protected]: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]
npm warn deprecated [email protected]: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting [email protected]
npm error code 1
npm error path /Users/kyleadams/Code/companycam/background-agents/node_modules/sharp
npm error command failed
npm error command sh -c node install/check.js || npm run build
npm error > [email protected] build
npm error > node install/build.js
npm error
npm error sharp: Attempting to build from source via node-gyp
npm error sharp: See https://sharp.pixelplumbing.com/install#building-from-source
npm error sharp: Please add node-addon-api to your dependencies
npm error A complete log of this run can be found in: 

2026-04-21T17_14_42_443Z-debug-0.log

I can provide the full log if needed. I added node-gyp and node-addon-apis as dev dependencies and that cleared up my build issues:

npm add -D node-gyp node-addon-api

I'm happy to submit a PR with the correct fix, whether that's explicitly adding those dependencies as above or some other route.

kadams54 avatar Apr 21 '26 17:04 kadams54

possibly related: https://github.com/lovell/sharp/issues/4498

ColeMurray avatar Apr 21 '26 20:04 ColeMurray

Having looked that over, I'm 99% sure that's what's happening for me as well. Interesting that building from source will be opt-in in the next sharp release, due to NPM tightening down the screws (long overdue) on install scripts.

kadams54 avatar Apr 22 '26 19:04 kadams54

Resolved on current main by the sharp upgrade in #2070 / #2359.

The root package.json overrides sharp to ^0.35.5, and package-lock.json resolves a single [email protected]. Unlike 0.34.5, that version has no install script. The node install/check.js || npm run build step that fell back to node-gyp and failed here no longer runs, and prebuilt @img/sharp-* binaries are used instead. This matches upstream lovell/sharp#4498, where building from source became opt-in. Adding node-gyp / node-addon-api is no longer necessary.

Closing. Please reopen if a fresh npm install still fails on your macOS / Node 24 setup.

open-inspect avatar Oct 25 '26 21:10 open-inspect