Yusuf Sham
Yusuf Sham

Reputation: 21

Puppeteer: Error: Could not find Chrome (ver. 113.0.5672.63)

In my node.js project hosted on AWS EC2, I am using puppeteer for converting a html content to PDF using puppeteer. Whenever I try to call the function.

I am getting the following error:

error: Could not find Chrome (ver. 113.0.5672.63). This can occur if either

you did not perform an installation before running the script (e.g. npm install) or
your cache path is incorrectly configured (which is: /root/.cache/puppeteer). For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. Error: Could not find Chrome (ver. 113.0.5672.63). This can occur if either
you did not perform an installation before running the script (e.g. npm install) or
your cache path is incorrectly configured (which is: /root/.cache/puppeteer). For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration. at ChromeLauncher.resolveExecutablePath (/var/app/current/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:301:27) at ChromeLauncher.executablePath (/var/app/current/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:182:25) at ChromeLauncher.computeLaunchArguments (/var/app/current/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ChromeLauncher.js:98:37) at async ChromeLauncher.launch (/var/app/current/node_modules/puppeteer-core/lib/cjs/puppeteer/node/ProductLauncher.js:83:28)

I tried different solutions like:

  1. Defining an env variable PUPPETEER_SKIP_DOWNLOAD=true.
  2. upgrading/downgrading node version. Could anyone please help me out!

My application's production server is getting crashed.

I tried calling an API which converts an HTML into a PDF and starts downloading it. But the server returns the above error.

Upvotes: 2

Views: 2000

Answers (2)

Benjamin Gakami
Benjamin Gakami

Reputation: 1749

just run

node node_modules/puppeteer/install.js

or

node node_modules/puppeteer/install.mjs

That should install headless chrome and you should be good to go.

Upvotes: 0

Allan Chua
Allan Chua

Reputation: 10185

This happens most of the time because the Chromium that gets installed on your development/build machine is not compatible with the underlying architecture of the EC2 instance. To solve this, you have two options:

  • You will have to use a container that simulates the underlying architecture / operating system of the EC2 instance used for running the node js app. You can use this container to install node modules that were compatible to your environment's EC2 architecture. EG. If you are using an Amazon Linux 2 and x86 EC2, use an Amazon Linux 2 image built for x86 to spawn a container and run your build process inside by installing node modules for your app. The output of this process could then be deployed to your EC2 instance.

  • You will have to ship your build without the node modules and perform the npm i command inside the EC2 itself to get a chromium that is compatible with your EC2.

Upvotes: 2

Related Questions