Skip to content

Build from source fails on Node.js 24 LTS with globally-installed libvips #4498

@jechol

Description

@jechol

Possible install-time or require-time problem

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest (0.34.5).

Are you using a supported runtime?

  • I am using Node.js with a version that satisfies ^18.17.0 || ^20.3.0 || >=21.0.0

Are you using a supported package manager and installing optional dependencies?

  • I am using npm >= 10.1.0 with --include=optional

What is the complete error message, including the full stack trace?

When libvips is globally installed (e.g. via brew install vips), sharp attempts to build from source instead of using prebuilt binaries. This fails on Node.js 24 LTS:

sharp: Attempting to build from source via node-gyp
sharp: Detected globally-installed libvips v8.18.0
../metadata.cc:259:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
../metadata.cc:262:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
../metadata.cc:265:46: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
../metadata.cc:272:45: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
../metadata.cc:276:31: error: no member named 'NewOrCopy' in 'Napi::Buffer<char>'
5 errors generated.
make: *** [Release/obj.target/sharp-darwin-arm64/metadata.o] Error 1
gyp ERR! build error

What is the complete output of running npm install --verbose --foreground-scripts sharp in an empty directory?

Details
sharp: Attempting to build from source via node-gyp
sharp: See https://sharp.pixelplumbing.com/install#building-from-source
sharp: Please add node-addon-api to your dependencies
npm error code 1
npm error path /private/tmp/sharp-test/node_modules/sharp
npm error command failed
npm error command sh -c node install/check.js || npm run build

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System:
  OS: macOS 26.2
  CPU: (10) arm64 Apple M1 Pro
  Memory: 110.91 MB / 16.00 GB
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 24.13.0
  npm: 11.6.2

Workaround: SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install sharp forces prebuilt binary download and succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions