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
  • PDF

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 a year ago
  • Comments: 71

Commits related to this issue

Most upvoted comments

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 :

  • operating a clean install of all packages with : npm clean-install
  • cleaning the npm cahe with : npm cache clean --force
  • adding a gcp-build script to install chrome after deployment on Firebase Hosting with this : "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…)
  • adding a puppeteer.config.js as detailed in the puppeteer docs : https://pptr.dev/guides/configuration/#changing-the-default-cache-directory

Unfortunately, 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/puppeteer folder does not install every time. On ten tries, the .cache/puppeteer directory 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.

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).

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:

  1. Create a file named .puppeteerrc.cjs in your root folder.

  2. Add the following content to the file:

    const { join } = require('path');
    
    /**
     * @type {import("puppeteer").Configuration}
     */
    module.exports = {
      // Changes the cache location for Puppeteer.
      cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
    };
    
  3. Update your docker file with the following step after npm install: RUN npx puppeteer browsers install chrome

  4. Deploy 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

linux/ubuntu, node v16.20.2 here - after npm i puppeteer I ran node node_modules/puppeteer/install.mjs

dgtlmoon:~$ node node_modules/puppeteer/install.mjs
Downloading chrome r117.0.5938.149 - 149.1 MB [====================] 100% 0.0s 
Chrome (117.0.5938.149) downloaded to /home/dgtlmoon/.cache/puppeteer/chrome/linux-117.0.5938.149

All good 😃

@besnikh

I have been awake last 3 days with this 😦 Even ChatGPT couldn’t help me 😃

These are my files that I managed to run Puppeteer on Docker and Google Cloud Run

Dockerfile

FROM node:latest

WORKDIR /app

COPY package.json yarn.lock ./

RUN yarn install

COPY . .

# Install puppeteer dependencies
RUN apt-get update && apt-get install -y \
    wget \
    gconf-service \
    libasound2 \
    libatk1.0-0 \
    libcairo2 \
    libcups2 \
    libfontconfig1 \
    libgdk-pixbuf2.0-0 \
    libgtk-3-0 \
    libnspr4 \
    libpango-1.0-0 \
    libxss1 \
    fonts-liberation \
    libappindicator1 \
    libnss3 \
    lsb-release \
    xdg-utils

ENV PUPPETEER_DOWNLOAD_PATH=/usr/local/chromium

RUN yarn add puppeteer

EXPOSE 4000

CMD ["yarn", "start"]

Some parts of index.js

const browser = await puppeteer.launch({
    headless: "new",
    args: [
      '--no-sandbox',
      '--disable-dev-shm-usage'
    ],
  });

await page.goto(url, { waitUntil: 'domcontentloaded' });

Hope this helps someone but I don’t know what happened with that Chromium it killed me

this worked for me

FROM node:18

WORKDIR app

COPY package.json .
COPY package-lock.json .
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 libxss1 \
   libx11-xcb1 \
   libxtst6 \
   libnss3 \
   libxss1 \
   libasound2 \
   libatk-bridge2.0-0 \
   libgtk-3-0 \
   --no-install-recommends \
   && rm -rf /var/lib/apt/lists/*

COPY . .

EXPOSE 8080

CMD ["npm", "start"]

I already add .pupeteerrc.cjs in project. Locally this thing works for me, but it doesn’t work in digital ocean server.

Running into the same issue. This is my first time installing Puppeteer. When I check chromium-browser --product-version it returns 115.0.5790.102, but trying to run the script calling Puppeteer returns an error that includes Could 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.

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@19

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

Same here, can confirm that install.mjs script doesn’t help anymore. Running AWS Lambda functions based on Docker container with this setup:

FROM public.ecr.aws/lambda/nodejs:16

RUN curl -O https://lambda-insights-extension.s3-ap-northeast-1.amazonaws.com/amazon_linux/lambda-insights-extension.rpm && \
    rpm -U lambda-insights-extension.rpm && \
    rm -f lambda-insights-extension.rpm

RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras install epel -y

ADD https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm chrome.rpm
RUN yum install -y ./chrome.rpm

COPY ./  ./
RUN ls
RUN npm install
RUN node node_modules/puppeteer/install.mjs

CMD [ "index.handler" ]


I’m still got the same problem

Node: v18.17.1

Already install the puppeteer by npm install puppeteer and run cd node_modules && node puppeteer/install.mjs It returns Chrome (119.0.6045.105) downloaded to /home/master/.cache/puppeteer/chrome/linux-119.0.6045.105

I check the ~/.cache/puppeteer/chrome, and there is a file directory name linux-119.0.6045.105 with its sub directories chrome-linux64

Still not work after all these steps 😦( Please help

I have the same problem:

error: “Could not find Chrome (ver. 114.0.5735.133). This can occur if either\n 1. you did not perform an installation before running the script (e.g. npm install) or\n 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).\nFor (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.

I also tried all of the measures below:

  • operating a clean install of all packages with : npm clean-install
  • cleaning the npm cahe with : npm cache clean --force
  • adding a gcp-build script in package.json to install chrome after deployment on Firebase Hosting with this : “gcp-build”: “node node_modules/puppeteer/install.js” (doens’t seem to do anything!)
  • increasing the allocated memory to 1024M
  • adding a puppeteer.config.js as detailed in the puppeteer docs : https://pptr.dev/guides/configuration/#changing-the-default-cache-directory

but nothing worked!

I’m not sure if the .puppeteer.config.cjs file should be placed in the root directory or in the functions folder:

Screenshot 2023-07-03 at 19 08 29

EDIT: I changed the filename to puppeteer.config.cjs and placed it in the functions folder. After deploying, a .cache folder was created with a very large number of files. firebase deploy ended with:

⚠ functions: Upload Error: HTTP Error: 400, EntityTooLargeYour proposed upload is larger than the maximum object size specified in your Policy Document.Content-length exceeds upper bound on range

linux/ubuntu, node v16.20.2 here - after npm i puppeteer I ran node node_modules/puppeteer/install.mjs

dgtlmoon:~$ node node_modules/puppeteer/install.mjs
Downloading chrome r117.0.5938.149 - 149.1 MB [====================] 100% 0.0s 
Chrome (117.0.5938.149) downloaded to /home/dgtlmoon/.cache/puppeteer/chrome/linux-117.0.5938.149

All good 😃

Confirming this fix also.

I have the same problem:

error: “Could not find Chrome (ver. 114.0.5735.133). This can occur if either\n 1. you did not perform an installation before running the script (e.g. npm install) or\n 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).\nFor (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.

I also tried all of the measures below:

  • operating a clean install of all packages with : npm clean-install
  • cleaning the npm cahe with : npm cache clean --force
  • adding a gcp-build script in package.json to install chrome after deployment on Firebase Hosting with this : “gcp-build”: “node node_modules/puppeteer/install.js” (doens’t seem to do anything!)
  • increasing the allocated memory to 1024M
  • adding a puppeteer.config.js as detailed in the puppeteer docs : https://pptr.dev/guides/configuration/#changing-the-default-cache-directory

but nothing worked! I’m not sure if the .puppeteer.config.cjs file should be placed in the root directory or in the functions folder: Screenshot 2023-07-03 at 19 08 29 EDIT: I changed the filename to puppeteer.config.cjs and placed it in the functions folder. After deploying, a .cache folder was created with a very large number of files. firebase deploy ended with:

⚠ functions: Upload Error: HTTP Error: 400, EntityTooLargeYour proposed upload is larger than the maximum object size specified in your Policy Document.Content-length exceeds upper bound on range

I’ve ended up with the same size issue. Bitbucket pipelines throws this error: Error: HTTP Error: 400, <?xml version='1.0' encoding='UTF-8'?><Error><Code>EntityTooLarge</Code><Message>Your proposed upload is larger than the maximum object size specified in your Policy Document.</Message><Details>Content-length exceeds upper bound on range</Details></Error>

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.

const install_puppeteer = async (): Promise<any> => {
  const cacheDirectory = join(process.cwd(), '.cache', 'puppeteer');
  const fs = require('fs');
  if (fs.existsSync(cacheDirectory)) {
    return;
  } else {
    const child = fork('node_modules/puppeteer/install.js')
    return await once(child, 'close');
  }
}

I would like to call this function after every deploy and not letting user wait for it. Is there a way to do it ?

await install_puppeteer();

linux/ubuntu, node v16.20.2 here - after npm i puppeteer I ran node node_modules/puppeteer/install.mjs

dgtlmoon:~$ node node_modules/puppeteer/install.mjs
Downloading chrome r117.0.5938.149 - 149.1 MB [====================] 100% 0.0s 
Chrome (117.0.5938.149) downloaded to /home/dgtlmoon/.cache/puppeteer/chrome/linux-117.0.5938.149

All good 😃

Confirming this fix also.

Run node_modules/puppeteer/install.js to download the binary

This works very well => in my case it was “node_modules/puppeteer/install.mjs” Thank you so much

Discovery: The cache in ...\.cache\puppeteer\chrome can be erroneous or not update. install.js might claim the version you need is installed, but the datetime stamp didn’t change. I got suspicious, so I deleted the old version, then ran node node_modules\puppeteer\install.js to pull it down again. My problem was fixed afterwards.

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\chrome can be erroneous or not update. install.js might claim the version you need is installed, but the datetime stamp didn’t change. I got suspicious, so I deleted the old version, then ran node node_modules\puppeteer\install.js to 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.

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.

Error: Could not find Chrome (ver. 114.0.5735.133). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /workspace/node_modules/puppeteer).

I don’t know why !

@sk8killer some people have commented that there might (have been/) be some issues with the server chrome binary is being downloaded from.

still 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.