After a couple days trying to fix this, Netlify seems to use sharp
module for no reason. My app completely purges all sharp
and image plugins supported by Gatsby officially such as gatsby-plugin-image
, gatsby-plugin-sharp
, and gatsby-transformer-sharp
. But the module still requires to be installed in my Netlify Function. Here is the complete log:
Feb 8, 02:04:45 PM: 90833ba3 Duration: 2025.95 ms Memory Usage: 124 MB
Feb 8, 02:04:46 PM: INFO Preparing Gatsby filesystem {
from: '/var/task/.cache',
to: '/tmp/gatsby/.cache',
rewrites: [
[ '/var/task/.cache/caches', '/tmp/gatsby/.cache/caches' ],
[
'/var/task/.cache/caches-lmdb',
'/tmp/gatsby/.cache/caches-lmdb'
],
[ '/var/task/.cache/data', '/tmp/gatsby/.cache/data' ]
]
}
Feb 8, 02:04:46 PM: INFO directory already exists
Feb 8, 02:04:47 PM: error Uncaught Exception {"errorType":"Error","errorMessage":"\nSomething went wrong installing the \"sharp\" module\n\nlibvips-cpp.so.42: cannot open shared object file: No such file or directory\n\nPossible solutions:\n- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"\n- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"\n- Consult the installation documentation: https://sharp.pixelplumbing.com/install","stack":["Error: ","Something went wrong installing the \"sharp\" module","","libvips-cpp.so.42: cannot open shared object file: No such file or directory","","Possible solutions:","- Install with verbose logging and look for errors: \"npm install --ignore-scripts=false --foreground-scripts --verbose sharp\"","- Install for the current linux-x64 runtime: \"npm install --platform=linux --arch=x64 sharp\"","- Consult the installation documentation: https://sharp.pixelplumbing.com/install"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:295955:9)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.defined (/var/task/.cache/query-engine/index.js:294775:1)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:294747:15)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:294735:18)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:294720:37)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:294226:43)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at Object.<anonymous> (/var/task/.cache/query-engine/index.js:293735:27)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"," at exports.__esModule (/var/task/.cache/query-engine/index.js:292810:28)"," at __webpack_require__ (/var/task/.cache/query-engine/index.js:311896:42)"]}
Feb 8, 02:04:47 PM: INIT_REPORT Init Duration: 1977.63 ms Phase: invoke Status: error Error Type: Runtime.Unknown
Feb 8, 02:04:47 PM: Unknown application error occurred
Runtime.Unknown
Feb 8, 02:04:47 PM: bd5babe5 Duration: 2035.12 ms Memory Usage: 124 MB
I decided to test it out on Vercel. Vercel also suffers the problem with installing sharp
module. However, after purging all the sharp
module and related dependencies for Gatsby, it works just fine.
For anyone who runs into these issues, I decide to go on with Vercel so I won’t investigate on this issue anymore. For Netlify engineers and support team, I hope you will take a look at this and resolve it. Thanks for reading.