catalystbyzohozohocatalystcatalystserverless

Unable to use Canvas package in my Catalyst Node function


I created a node function where I use the canvas package to send images(PNG) as response from my function. The function works fine when I run it from my local machine. But I am getting "Invalid ELF header" error when I try to execute the function from Development environment. Can someone help me resolve this?

You can also refer to the below screenshot for the same:enter image description here


Solution

  • You are getting this error "invalid ELF headers" because the canvas package throws the error "ERR_DLOPEN_FAILED".

    The error ERR_DLOPEN_FAILED typically occurs in Node JS when there is a problem loading native add-on modules or shared libraries. This error indicates that Node JS encountered an issue while attempting to dynamically load a shared library using the dlopen() method, which might occur if there is a package missing.

    I suspect since Canvas is an OS-dependent package, it worked on your local machine where you installed the same, but you got the ERR_DLOPEN_FAILED error since the same package is not recognised by the Catalyst server. It might indicate the catalyst server is running on a different OS architecture than the one you are using on your local machine.

    To resolve this error, you can either try installing the canvas package based on the Catalyst server OS architecture or, I highly suggest, try using a different (non dependent) package that works on any OS architecture.