diff --git a/docs/changelog.md b/docs/changelog.md index 29d5f2802..7c38cd04d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -18,6 +18,9 @@ Requires libvips v8.11.3 [#2918](https://github.com/lovell/sharp/pull/2918) [@dkrnl](https://github.com/dkrnl) +* Throw error rather than exit when invalid binaries detected. + [#2931](https://github.com/lovell/sharp/issues/2931) + ### v0.29.1 - 7th September 2021 * Add `lightness` option to `modulate` operation. diff --git a/lib/sharp.js b/lib/sharp.js index 7d0b72ed9..3fd037855 100644 --- a/lib/sharp.js +++ b/lib/sharp.js @@ -24,9 +24,8 @@ try { const loadedModule = Object.keys(require.cache).find((i) => /[\\/]build[\\/]Release[\\/]sharp(.*)\.node$/.test(i)); if (loadedModule) { const [, loadedPackage] = loadedModule.match(/node_modules[\\/]([^\\/]+)[\\/]/); - help.push(`- Ensure version aligns with: "npm ls sharp". Now sharp already loaded in: "${loadedPackage}"`); + help.push(`- Ensure the version of sharp aligns with the ${loadedPackage} package: "npm ls sharp"`); } } - console.error(help.join('\n')); - process.exit(1); + throw new Error(help.join('\n')); }