diff --git a/lib/constructor.js b/lib/constructor.js index c8ac4516..0f85b02a 100644 --- a/lib/constructor.js +++ b/lib/constructor.js @@ -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');