puppeteer: [Bug]: Error retrieving document: Error: Could not find Chrome (ver. 114.0.5735.90)
Bug expectation
I was trying to open a website for my scrapping that i hosted on cloud run, but the problem that i was encountering that when it run always gives me [Bug]: Error retrieving document: Error: Could not find Chrome (ver. 114.0.5735.90)
Bug behavior
- Flaky
Minimal, reproducible example
import cheerio from "cheerio";
import puppeteer from 'puppeteer';
import randomUseragent from 'random-useragent';
export const scrapeData = async (productName) => {
const product = productName.replace(/ /g, "+");
console.log(1);
const url = `https://www.tokopedia.com/search?st=product&q=${product}`;
const randomAgent = randomUseragent.getRandom();
const browser = await puppeteer.launch({
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
],
});
console.log(2);
const context = await browser.createIncognitoBrowserContext();
const page = await context.newPage();
await page.setJavaScriptEnabled(true);
await page.setUserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36");
const domLoadedPromise = new Promise((resolve) => {
page.once('load', resolve);
});
await page.goto(url, { waitUntil: 'networkidle0' });
// await page.waitForSelector('[data-testid="master-product-card"]');
await domLoadedPromise;
const body = await page.evaluate(() => {
return document.querySelector('body').innerHTML;
});
const $ = cheerio.load(body);
const listItems = $('[data-testid="master-product-card"]');
console.log(3);
var result
listItems.each(function (idx, el) {
var nama = $('[data-testid="spnSRPProdName"]', el).text();
var harga = $('[data-testid="spnSRPProdPrice"]', el).text();
var image = $('[data-testid="imgSRPProdMain"]', el).attr("src");
var link = $('a[href]', el).attr("href");
if (harga != null && harga != "") {
result = {
"Treatment for": productName,
"nama": nama,
"harga": harga,
"link": link,
"image": image
};
return false
}
});
console.log("Url: ", url);
console.log("For This Product: ", productName);
await browser.close();
return result;
};
Error string
Error retrieving document: Error: Could not find Chrome (ver. 114.0.5735.90)
Puppeteer configuration
# Use the official Node.js 14 image as the base
FROM node:18
# Set the working directory inside the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package.json package-lock.json ./
# Install project dependencies
RUN npm install
# Install necessary dependencies for Puppeteer
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
# Copy the rest of the project files to the working directory
COPY . .
# Start the Express application
CMD [ "npm", "run", "dev" ]
Puppeteer version
20.6.0
Node version
18
Package manager
npm
Package manager version
18
Operating system
Linux
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 83
Commits related to this issue
- Downgrade puppeteer to 19.11.0 in an attempt to fix https://github.com/puppeteer/puppeteer/issues/10388 — committed to zemn-me/monorepo by Zemnmez 3 years ago
- cache Puppeteer attempt to work around https://github.com/puppeteer/puppeteer/issues/10388 — committed to hudcostreets/ctbk.dev by ryan-williams 2 years ago
Run node_modules/puppeteer/install.js to download the binary
Same error for me with Firebase Hosting after deploying since yesterday :
Could not find Chrome (ver. 114.0.5735.133)I tried everything, but nothing works :npm clean-installnpm cache clean --force"gcp-build": "node node_modules/puppeteer/install.js"(doens’t work because node_modules doesn’t seem to be accessible from the root hosting directory…)puppeteer.config.jsas detailed in the puppeteer docs : https://pptr.dev/guides/configuration/#changing-the-default-cache-directoryUnfortunately, i tried to downgrade puppeteer to the previews working version for me on Firebase Hosting wich was 10.4.0 and it still doesn’t work.
This is very frustrating and urgent for me as part of the website i need to deploy is currently out of service !
I noticed that when I try to install puppeteer in local, the
.cache/puppeteerfolder does not install every time. On ten tries, the.cache/puppeteerdirectory has only been installed once.So I don’t think that it is a problem with Firebase Hosting but rather with Puppeteer or the Chrome install server.
This issue needs to be reopenned.
Figured I’d share the solution that worked for me, most of which is very similar to what others have already shared.
Create a
puppeteer.config.cjsfile in the root directory of your project:For Render, this wasn’t enough because after every new deployment, I’d get the same error that Chrome could’t be found. Using this answer, I added a command in my package.json file to install the appropriate version of chrome before starting the server:
Everything seems to be working now.
This bug is legendary. No matter what OS, environment or what year it is, always “Could not find Chrome”. Run “puppeteer browsers install chrome” -> getting “Could not find Chrome” afterwards anyway. Mind blowing truly
I switched to Puppeteer because I was facing EXACTLY the same issue with Playwright…
it is crazy how NO ONE has an proper answer to explain what is going on. Everything works perfectly but from the moment this is supposed to run from a Docker container, BOOM…nothing works as expected. In the beginning I thought “well, I am not a infra / devops guy so my Docker knowledge is very limited so that’s probably why I can’t get it working” but after months researching and trying EVERY single solution (first from Playwright and now Puppeteer) I am convinced that not even the maintainers can really explain why it does not work.
A lot of tries, a lot of different situations but not actual: THIS IS THE WAY 😅
So frustrating
Hey everyone,
I managed to resolve this issue by following the instructions outlined in this documentation.
Here’s a summary of the steps you need to take:
Create a file named
.puppeteerrc.cjsin your root folder.Add the following content to the file:
Update your docker file with the following step after npm install:
RUN npx puppeteer browsers install chromeDeploy your changes.
For local testing purposes, simply comment out the content in
.puppeteerrc.cjs.Following these steps, I successfully tested the flow on my Google Cloud Run instance. This approach might also work for Lambdas or Cloud Functions.
Let me know should you need any help
Same issue here:
Could not find Chrome (ver. 114.0.5735.133)I’m having the same issue.
error Could not find Chrome (ver. 114.0.5735.133).I’m seeing this too, was working fine but just stopped working on a fresh install. Does this always pull the latest chrome? Seen issues with this and Cypress before
I already add
.pupeteerrc.cjsin project. Locally this thing works for me, but it doesn’t work in digital ocean server.Same here, can confirm that install.mjs script doesn’t help anymore. Running AWS Lambda functions based on Docker container with this setup:
linux/ubuntu, node v16.20.2 here - after
npm i puppeteerI rannode node_modules/puppeteer/install.mjsAll good 😃
@besnikh
this worked for me
Running into the same issue. This is my first time installing Puppeteer. When I check
chromium-browser --product-versionit returns 115.0.5790.102, but trying to run the script calling Puppeteer returns an error that includesCould not find Chrome (ver. 115.0.5790.98). I tried adding a .puppeteerrc.cjs like @vvivan89 suggested. I uninstalled and reinstalled Puppeteer with npm, but I’m still getting the same error.Same issue here: Could not find Chrome (ver. 114.0.5735.133). I have added .puppeteerrc.cjs, but when deploy to Firebase function (node 18), the error still appears. I have tried to set the cache dir tobe under different folder like .cache, node_modules, but none of it works. I think it might related to how firebase-tools deploy the bundle.
The problem I encountered: Using version 20, I downloaded a zip file in the $HOME/. cache/puppeteer/chrome folder, but the file was not successfully extracted. I attempted to manually extract it but also failed.
Guess: There is an issue downloading the compressed package, link Chrome for Testing in github README I am unable to access and feel puzzled.
Solution: I have specified to install version 19 instead of the default version 20.
yarn add puppeteer@19still experiencing this as well:
Could not find Chrome (ver. 114.0.5735.90)the bug happened when i was trying to connect browser const browser = await puppeteer.launch({ headless: true, args: [ ‘–no-sandbox’, ‘–disable-setuid-sandbox’, ], });
I configured docker file to install all dependencies that was needed to run at cloud.
This is how my issue was solved, had to install it manually on Amazon Linux 2023. https://github.com/amazonlinux/amazon-linux-2023/discussions/417#discussioncomment-6724153
just npm uninstall puppeteer and then reinstall it npm i puppeteer
I’m still got the same problem
Node: v18.17.1
Already install the puppeteer by
npm install puppeteerand runcd node_modules && node puppeteer/install.mjsIt returnsChrome (119.0.6045.105) downloaded to /home/master/.cache/puppeteer/chrome/linux-119.0.6045.105I check the
~/.cache/puppeteer/chrome, and there is a file directory name linux-119.0.6045.105 with its sub directories chrome-linux64Still not work after all these steps 😦( Please help
In my case everything works perfectly when i first deploy the firebase function, but after the next deploy it throws error "Could not find Chrome… ", and maybe it would happen even with a new instance of the function (not sure about that) My guess is that gcp-build is not always running so i tried running node node_modules/puppeteer/install.js in my function using fork(). After installing it “manually” it works again.
I would like to call this function after every deploy and not letting user wait for it. Is there a way to do it ?
Confirming this fix also.
This works very well => in my case it was “node_modules/puppeteer/install.mjs” Thank you so much
Yes that worked. Delete the current version from cache and run
node node_modules\puppeteer\install.mjs(Extension was mjs, not js in my case)Discovery: The cache in
...\.cache\puppeteer\chromecan be erroneous or not update.install.jsmight claim the version you need is installed, but the datetime stamp didn’t change. I got suspicious, so I deleted the old version, then rannode node_modules\puppeteer\install.jsto pull it down again. My problem was fixed afterwards.Facing the same issue with version 114.0.5735.133 Had to change downloaded version using “browserRevision” in the .puppeteerrc.cjs:
browserRevision: '117.0.5897.0'This version resolved the issue.
The latest downloadable version could be found here.
@sk8killer some people have commented that there might (have been/) be some issues with the server chrome binary is being downloaded from.
UPDATE 29/06/2023 : Everything works now like a charm today… I don’t know why !
Having the same issue. I did all the steps from creating the config file to adding the launch parameters to puppeteer, but nothing seems to be working. I have the .cache directory with the chrome version inside it, but I still get the error “Error: Could not find Chrome (ver. 114.0.5735.133)” Any help would be appreciated.
can i know how to resolve this?
On Fri, 16 Jun 2023 at 22.40 Junxiao Shi @.***> wrote:
I’m seeing Chromium download failure too. https://github.com/yoursunny/NDNts/actions/runs/5291639615/jobs/9577451367#step:6:94
The server is refusing connection from GitHub Actions. However, I can connect to it from local desktop.