3

This is just for describing the issue and sharing my solution, I got stuck a lot of time on it.

This issue happened after I upgraded the Angular 10 -> 11 and changed the builder from udk:udk-runner to @angular-devkit

The issue I was facing is when I set the field bundleDependencies in angular.json to true . The Puppeteer cannot start with the error cannot launch the browser

enter image description here

Then I found it also happened on the other external libraries I'm using at the Server side like BullJS Bull-Board Puppeteer-Cluster with the below error

enter image description here

Github source for demo the issue: https://github.com/phattranky/angular-ssr-error-with-pupepteer

Phat Tran
  • 3,404
  • 1
  • 19
  • 22

1 Answers1

4

The solution is quite simple you just need to add externalDependencies below the field bundleDependencies, which are the libraries we are using.

"externalDependencies": ["puppeteer", "puppeteer-cluster", "bull", "bull-board"]

Sample:

enter image description here

What is the externalDependencies ?

https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/builders/server/schema.json

enter image description here

If you have the better solution and any feedbacks, please share for me. Thanks

Hoang Subin
  • 6,610
  • 6
  • 37
  • 56
Phat Tran
  • 3,404
  • 1
  • 19
  • 22
  • Thank you very much for this! On the off chance someone finds this due to the same problem I had: "Error: Evaluation failed: ReferenceError: _waitForPredicatePageFunction is not defined" brought me here. Adding comment, so it may show up in a search. I had found a workaround for the initial problem (Chrome not starting), by passing the executablePath like so: puppeteer.launch({executablePath: /.../node_modules/puppeteer/.local-chromium/linux-v3r510n/chrome-linux/chrome"}); This makes some of puppeteer work but leads to follow-up issues. Your solution is much better. – SLLegendre Jan 30 '22 at 23:00