Unable to locate module 'puppeteer-core/internal/puppeteer-core.js' in 'puppeteer.js'

I'm attempting to integrate the newest version of Puppeteer (21.3.8) for generating PDFs from HTML/CSS in my React application. The challenge I'm facing involves certain HTML/CSS elements behaving improperly with tables in 'printing mode' (using WIN+P or CMD+P), such as incorrect page breaks.

While testing with Puppeteer version 21.3.8, I encounter the following error when running tests that previously functioned with older versions (less than 19.4.0):

Unable to locate module 'puppeteer-core/internal/puppeteer-core.js' in 'puppeteer.js'

My configurations include Jest version: jest: ^24.9.0 along with React Testing Library!

I am hesitant to downgrade Puppeteer, as this would disrupt my PDF generation capabilities. If anyone has potential solutions or recommendations, I would greatly appreciate your help. Thank you! :)

Here’s what I have attempted so far:

  • Downgraded Puppeteer to version 18.1.0, which resolved the tests but broke functionality.

  • Installed versions between 18.1.0 and 21.3.8, leading to a situation where either the functionality worked or the tests passed, but not both.

  • Experimented with packages such as puppeteer-extra and adjusted executablePath(), but none of these actions yielded success.

Hey Finn_Mystery, sounds frustrating! Here's a quick fix you can try:

  • Check if all Puppeteer-related imports are consistent across your project files. Replace any direct imports of internal modules with proper public APIs.

  • Update Jest to a more recent version (ideally v26+) to enhance compatibility.

  • Ensure Puppeteer is correctly installed in your node_modules, and its version aligns with any dependent libraries. Run a clean install by deleting node_modules and package-lock.json, then run npm install.

Give these a shot, and let me know if it helps. Good luck! 👍