I'm trying to run some NodeJS code using Sharp and i'm getting the following error:
[root@localhost myapp-backend]# node server.js
module.js:340
throw err;
^
Error: Cannot find module './build/Release/sharp'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/myapp-backend/node_modules/sharp/index.js:11:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/myapp-backend/server.js:277:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:935:3
Any ideas?
Thank you.
Turns out the Debian 8.x distribution I used did not include vips but I did not get an error message. Running
apt-get install libvips
followed by
npm install sharp
resolved the problem and sharp is finally installed and working.
It's probably due to Sharp not getting installed. When I installed it via
npm, there were no errors, but when I went into node_modules/sharp
, three were no build files.
You can try to build it by doingnode-gyp rebuild
But, before that, make sure you have Vips installed - that's a lib that Sharp uses. On Mac you'd dobrew install homebrew/science/vips --with-webp --with-graphicsmagick
After you build the Sharp library, you should be good to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With