In the original Stretch-based image, Puppeteer can be installed and used right out-of-the-box. However with the Default Codespaces “universal” image now based on Ubuntu 20.04, it no longer works.
First, it errors out:
/home/codespace/workspace/timelapse/main.js:120 throw up ^ Error: Failed to launch the browser process! /home/codespace/workspace/timelapse/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md at onClose (/home/codespace/workspace/timelapse/node_modules/puppeteer/lib/Launcher.js:750:14) at Interface.<anonymous> (/home/codespace/workspace/timelapse/node_modules/puppeteer/lib/Launcher.js:739:50) at Interface.emit (events.js:327:22) at Interface.close (readline.js:424:8) at Socket.onend (readline.js:202:10) at Socket.emit (events.js:327:22) at endReadableNT (_stream_readable.js:1327:12) at processTicksAndRejections (internal/process/task_queues.js:80:21)
I tried to
sudo apt install chromium-browser. This causes Chromium to be installed but still cannot launch either Chromium or Puppeteer because it is now a snap-only package and the required deps are no longer installed via apt.
One solution I tried is to revert back to Stretch-based images. This works but starting a new Codespace takes almost 10 minutes.
This seems to be the problem with Codespaces’ image, because I also confirmed that GitHub Actions with
runs-on: ubuntu-20.04 can also run Puppeteer out-of-the-box.
It would be great if the new Ubuntu 20.04-based image could run Puppeteer out-of-the-box without the need for any extra configuration like before.