Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working on local but not as AWS Lambda code #111

Open
lahoti-piyush opened this issue Jun 12, 2023 · 5 comments
Open

Working on local but not as AWS Lambda code #111

lahoti-piyush opened this issue Jun 12, 2023 · 5 comments

Comments

@lahoti-piyush
Copy link

lahoti-piyush commented Jun 12, 2023

AWS Lambda Runtime: Node.js 18.x

spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom\bin\phantomjs.exe ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn /var/task/node_modules/phantomjs-prebuilt/lib/phantom\\bin\\phantomjs.exe',
  path: '/var/task/node_modules/phantomjs-prebuilt/lib/phantom\\bin\\phantomjs.exe',
  spawnargs: [
    '--local-url-access=false',
    '--local-url-access=false',
    '/var/task/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js'
  ]
}
@muhammadyusuf-kurbonov
Copy link

muhammadyusuf-kurbonov commented Jun 13, 2023

It would help if you run npm rebuild on the server side to build phantomjs binaries for specific platforms. I have Linux VPS and it's helped me.
P.s.: I've no experience with AWS Lambda, so I can't provide direct instructions.

@Abutahir12
Copy link

Abutahir12 commented Jul 4, 2023

you will need to add a phantom js binary and provide the path, along with that, you need to provide the path to pdf_a4_portrait.js file

childProcessOptions: {
      env: {
        OPENSSL_CONF: "/dev/null"
      }
    },
    localUrlAccess: true,
    phantomPath: "/opt/nodejs/executables/executables/phantomjs_linux-x86_64",
    script: "/opt/nodejs/executables/executables/scripts/pdf_a4_portrait.js"
   };

In my case I have added these files in the layer and provided the path, add the above configuration in options
Try downloading the phantom js from here, make sure you download the correct file according to OS in your lambda environment
https://phantomjs.org/download.html

@junaidranjha
Copy link

@lahoti-piyush did you find any solution?

@martinGM05
Copy link

So ?, Did you find any solutions? 2024 :'(

@lahoti-piyush
Copy link
Author

So ?, Did you find any solutions? 2024 :'(

yes, added a chromium-layer to lambda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants