You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enhancement: support building from source with npm v12+ #4458
This issue only affects those building sharp from source, which include those using a globally-installed libvips.
There are some upstream changes to npm v11 relating to "unknown" flags, will move from warning to error in npm v12 - see npm/cli#8153
Those affected by this may have seen the following warning:
npm warn Unknown cli config "--build-from-source". This will stop working in the next major version of npm.
At the moment the scenarios that result in sharp being built from source:
a globally-installed libvips is detected
the npm install --build-from-source flag is used
...plus there is some control over these via the SHARP_IGNORE_GLOBAL_LIBVIPS and SHARP_FORCE_GLOBAL_LIBVIPS environment variables.
The upstream advice seems to be the use of an environment variable prefixed with npm_package_config_, and we can use this opportunity to consolidate all the above logic into a single environment variable, something like npm_package_config_sharp_global_libvips.
This might behave a bit like Meson's tri-state features option, however I'm not a fan of the disabled/enabled wording, so this needs a little more thought, perhaps allowing values such as force, ignore and auto.
Having now investigated this, a much simpler solution is to move the generic install script to a dedicated "I know I want to build sharp from source" script instead, which could be run using something like:
// PROPOSAL, NOT YET IMPLEMENTED
npm install package-that-depends-on-sharp
npm explore sharp -- npm run build
This approach would still respect existing environment variables, but would remove deprecate support for the --build-from-source flag.
changed the title [-]Possible breaking change for those building from source with npm v12[/-][+]Enhancement: support building from source with npm v12+[/+]on Oct 7, 2025
Activity
lovell commentedon Oct 3, 2025
Having now investigated this, a much simpler solution is to move the generic
installscript to a dedicated "I know I want to build sharp from source" script instead, which could be run using something like:This approach would still respect existing environment variables, but would
removedeprecate support for the--build-from-sourceflag.Separate build script from install script #4458
[-]Possible breaking change for those building from source with npm v12[/-][+]Enhancement: support building from source with npm v12+[/+]chore(deps): update dependency sharp to ^0.35.5 (#9)