0
votes

We have created AWS Lambda function to generate html to pdf dynamically in nodejs4.3 eun environment using html-pdf library.

That function is working well in workstation. We are getting the below exception when test in AWS Lambda.

Error Details:

{ "errorMessage": "spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT", "errorType": "Error", "stackTrace": [ "exports._errnoException (util.js:870:11)", "Process.ChildProcess._handle.onexit (internal/child_process.js:178:32)", "onErrorNT (internal/child_process.js:344:16)", "nextTickCallbackWith2Args (node.js:437:9)", "process._tickDomainCallback (node.js:392:17)" ]

Can any one advise me, how to resolve this issue.

1
The binary of phantomJS is not found it seemsVaviloff
Take a look at this example setup - github.com/lubos/aws-lambda-wkhtmltopdfVlad Holubiev

1 Answers

2
votes

The error is raised because you don't have PhantomJS binary

/var/task/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe

that is supposed to save an HTML page to PDF.

But even if you would have that binary packed with you Lambda function, it still wouldn't work: the *.exe extension clearly suggests it's a Microsoft Windows executable. You will need the Linux version to run in AWS Lambda.