Add warning if sharp bindings aren't built correctly (#1638)

This commit is contained in:
Sidhartha Chatterjee 2019-04-02 21:30:55 +05:30 committed by Lovell Fuller
parent 0a3512d066
commit 2e0fbbb942

View File

@ -7,7 +7,25 @@ const events = require('events');
const is = require('./is');
require('./libvips').hasVendoredLibvips();
const sharp = require('bindings')('sharp.node');
let sharp;
try {
sharp = require('bindings')('sharp.node');
} catch (error) {
// 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
`
);
throw error;
}
// Use NODE_DEBUG=sharp to enable libvips warnings
const debuglog = util.debuglog('sharp');