Error: Could not find browser revision 756035. Run "npm install"

Viewed 14583

My code is as follows:

 const browser = await puppeteer.launch({headless: params["headless"]});

 
    const page = await browser.newPage();
    await page.setJavaScriptEnabled(true);
    await page.setRequestInterception(true);
...

The issue is that I am unable to run it. I am getting following exception.

(node:7008) UnhandledPromiseRejectionWarning: Error: Could not find browser revision 756035. Run "npm install" or "yarn install" to download a browser binary.
    at ChromeLauncher.launch (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\node_modules\puppeteer\lib\Launcher.js:59:23)
    at async browse (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:126:19)
    at async tryExecute (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:73:5)
    at async sequentialFor (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:416:5)
    at async tryExecute (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:60:5)
    at async sequentialFor (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:416:5)
    at async tryExecute (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:60:5)
    at async httpBlock (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:268:5)
    at async tryExecute (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:64:5)
    at async sequentialFor (C:\Users\rpaadmin\.jenkins\workspace\ikinciyeni\generic_scrapper\main_2.0_temp.js:416:5)
(node:7008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

How do I fix it ? It was working just fine before.

4 Answers

If anyone else is facing similar issue then delete node modules folder and run again. It will work

No need to delete all node_modules folder

Run npm i puppeteer and it will update your revision of chromium

If any of the above solutions don't work, in my case (running on ubuntu 16.04.3 LTS on a digitalocean droplet) this error was caused because npm refused to install chromium as a dependency of puppeteer. I don't know the cause of this behavior, but I've seen it reported elsewhere. I'm using the full version of puppeteer, not puppeteer-core.

What worked for me was to manually install chromium via npm:

npm install chromium

And then in my puppeteer script, explicitly set the executable:

puppeteer.launch({
  executablePath: './node_modules/chromium/lib/chromium/chrome-linux/chrome',
  // be sure to verify that this path matches your installation, but this is where npm put it in my node_modules directory
  // and of course include any other launch arguments you need here
});

But I'd sure love to know if there's a better solution than this.

For future references, I had to do the following to make it work on my ubuntu server (launching Chrome):

  1. Point to your local chromium (launch option - executablePath, in my case : node_modules/puppeteer/.local-chromium/linux-809590/chrome-linux/chrome')

  2. Update your packages :

sudo apt-get install libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libgconf2-4 libasound2 libatk1.0-0 libgtk-3-0

  1. Add that sneaky package :

sudo apt-get install -y libgbm-dev

Related