简体   繁体   中英

Can't Use Puppeteer -- Error: Failed to launch chrome

This is the error I get. This occurs when the test code is run in the Gitlab CI.

However, it works fine locally. Someone please help?

2036 $ npm test

2037 > 10_auth@1.1.3 test /builds/brhanuh/domestic-repair

2038 > jest --coverage 'unitTests/'

2039 Error: Failed to launch chrome!

2040 /builds/brhanuh/domestic-repair/node_modules/puppeteer/.local-chromium/linux-686378/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory

Install the missing packages using

sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

Credits to @coldner on the puppetteer issue tracker for assembling the required pkgs.

If you encounter E: Unable to locate package errors, run sudo apt-get update .

I just wanted to add to @mohammad's answer, that now Puppetteer now has an official troublshooting guide that helps you determine what to install.

Also, they recommend running the following command to tell which particular packages need installing on *nix systems :

ldd chrome | grep not

Or, if you have Chrome installed via Puppetteer via NPM like me:

ldd ./node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome | grep not

Then, I was able to see what libraries were still missing, and install accordingly.

you need to install required dependencies

here

https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

under Chrome headless doesn't launch on UNIX you can find

Debian (e.g. Ubuntu) Dependencies
CentOS Dependencies

For those that are still having this problem, you can try this.

sudo apt update && sudo apt install -y ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libglib2.0-0 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 lsb-release wget xdg-utils

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM