AWS Layer gives EPIPE error

Following is the serverless version that I am using

Framework Core: 1.77.1
Plugin: 3.6.18
SDK: 2.3.1
Components: 2.33.1

I followed the blog post https://www.serverless.com/blog/publish-aws-lambda-layers-serverless-framework and https://medium.com/@keyurbhole/html-to-pdf-using-aws-lambda-functions-and-layers-with-serverless-92e70bb76a1a to create a html to pdf solution for my lambda…
I declared all the variables as exactly as given on the blog post…
But still i get

{
    "errno": "EPIPE",
    "code": "EPIPE",
    "syscall": "write"
  }

the code runs in local though.