Haris George
Haris George

Reputation: 359

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!

Upvotes: 1

Views: 2799

Answers (1)

Subhendu Sett
Subhendu Sett

Reputation: 71

For Ubuntu 18.04.5 sudo apt-get install -y libfontconfig sudo apt-get install -y libfreetype6

This works for me. I got the reference from here https://github.com/ariya/phantomjs/issues/13597

Upvotes: 7

Related Questions