mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 15:25:07 +01:00
Enhancement to and changelog entry for #1638
Remove bindings dependency as this isn't really... required
This commit is contained in:
@@ -9,22 +9,24 @@ const is = require('./is');
|
||||
require('./libvips').hasVendoredLibvips();
|
||||
|
||||
let sharp;
|
||||
|
||||
try {
|
||||
sharp = require('bindings')('sharp.node');
|
||||
} catch (error) {
|
||||
sharp = require('../build/Release/sharp.node');
|
||||
} catch (err) {
|
||||
// Bail early if bindings aren't available
|
||||
console.error(
|
||||
`
|
||||
"sharp" does not seem to have been built or installed correctly.
|
||||
|
||||
- Try to reinstall packages and look for errors during installation
|
||||
- Consult "sharp" installation page at http://sharp.pixelplumbing.com/en/stable/install/
|
||||
|
||||
If neither of the above work, please open an issue in https://github.com/lovell/sharp/issues
|
||||
`
|
||||
const help = ['', 'Something went wrong installing the "sharp" module', '', err.message, ''];
|
||||
if (/NODE_MODULE_VERSION/.test(err.message)) {
|
||||
help.push('- Ensure the version of Node.js used at install time matches that used at runtime');
|
||||
} else if (/invalid ELF header/.test(err.message)) {
|
||||
help.push(`- Ensure "${process.platform}" is used at install time as well as runtime`);
|
||||
} else {
|
||||
help.push('- Remove the "node_modules/sharp" directory, run "npm install" and look for errors');
|
||||
}
|
||||
help.push(
|
||||
'- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/',
|
||||
'- Search for this error at https://github.com/lovell/sharp/issues', ''
|
||||
);
|
||||
throw error;
|
||||
console.error(help.join('\n'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Use NODE_DEBUG=sharp to enable libvips warnings
|
||||
|
||||
Reference in New Issue
Block a user