Skip to main content

Symptom

npm install -g @testmuai/kane-cli fails with:
This can happen on any Node version (18, 20, 22, 26) and any platform (macOS, Linux, Windows).
sharp is an optional dependency of Kane CLI, so the install succeeds even if sharp fails. Screenshots then upload as PNG instead of WebP (~30% larger, with no functional impact). Requires Kane CLI 0.3.4 or later. To upgrade, run npm install -g @testmuai/kane-cli@latest.

Root cause

Kane CLI uses sharp to compress screenshots from PNG to WebP during upload. This compression is optional. sharp 0.34 and later deliver the native binary through platform-specific optional packages (@img/sharp-darwin-arm64, etc.). When sharp cannot load its prebuilt binary, it tries to build from source instead. That build fails because node-addon-api is not present. The three most common triggers, from most to least likely:

1. System libvips detected (macOS, most common)

sharp’s install/check.js runs pkg-config --modversion vips-cpp. If it finds a system-wide libvips, it skips the bundled prebuilt binary and tries to compile against the system copy. That always leads to the source-build failure. How libvips gets on your system: several Homebrew formulas install it as a dependency, so you probably did not install it yourself. The most common sources:
  • brew install appium: Appium depends on vips for image processing
  • brew install imagemagick: pulls vips as a dependency on some configurations
  • brew install gdal, brew install inkscape: other graphics-heavy formulas
Diagnosis:
Fix:

2. npm skipped optional dependencies

sharp lists its platform-specific packages (@img/sharp-darwin-arm64, etc.) under optionalDependencies. If npm is set to skip optional dependencies, the prebuilt binary is never downloaded and sharp tries to build from source. Diagnosis:
Fix:

3. Proxy or firewall blocking @img/* packages

sharp’s prebuilt packages are published under the @img npm scope on the public registry. If a corporate proxy, firewall, or private registry mirror does not forward @img/*, the downloads fail silently (npm does not treat a failed optional download as an error), and sharp tries to build from source. Diagnosis:
Fix: Make sure your proxy or registry mirror forwards the @img scope. If you use a private registry (Artifactory, Verdaccio, GitHub Packages), add a pass-through in your .npmrc:

Impact when sharp is unavailable

sharp is an optional dependency of Kane CLI. When sharp is not installed:
  • The install succeeds and does not crash
  • Screenshots upload as PNG instead of WebP (~30% larger)
  • Everything else in Kane CLI works normally
  • No warning is printed (npm hides install script output for global installs)
No action is required if slightly larger screenshot uploads are fine for you. You need the fixes above only if you want WebP compression.

Quick reference