Error: html-pdf: Received the exit code '127' in lambda nodejs

I am using "html-pdf" module in my lambda function. The below is my code

            await pdf.create(html, options).toStream(async function (err, stream) {
             if(err) {
               return err;
             }
            let fileName = NAME_OF_FILE;
            let key = KEY;
            let data = await s3Upload(key, stream) // function to upload to s3
        });

Code seems to be working fine in local. But in lambda I’m getting this error

Error: html-pdf: Received the exit code ‘127’
/var/task/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

Any ideas ? Thanks in advance!

18 thoughts on “Error: html-pdf: Received the exit code '127' in lambda nodejs”

Leave a Comment