Module 'puppeteer-core/internal/puppeteer-core.js' not found error in puppeteer.js

I’m working on a React application that generates PDFs from HTML and CSS using puppeteer version 21.3.8. Everything was working fine with older versions like 19.4.0, but after upgrading I keep getting this error:

Module 'puppeteer-core/internal/puppeteer-core.js' not found in puppeteer.js

The main reason I upgraded was because the older versions had problems with CSS layout when converting to PDF, especially with table elements breaking at wrong places during print mode.

My current setup includes:

The PDF generation works perfectly with the new version, but my test suite fails completely. Here’s what I already tried:

Attempted Solutions:

  • Downgraded to version 18.1.0 (tests pass but PDF issues return)
  • Tested various versions between 18.1.0 and 21.3.8 (always one feature breaks)
  • Experimented with puppeteer-extra package
  • Modified executablePath() settings

None of these approaches solved both problems simultaneously. Has anyone encountered this module resolution issue with newer puppeteer versions? Any suggestions would be greatly appreciated.

I hit the same issue upgrading puppeteer in a Node.js app. This module resolution error happens because newer puppeteer versions changed how they structure internal modules. What worked for me: delete node_modules completely and reinstall everything fresh. Package managers get confused when internal paths change during upgrades. Also check your test config for any hardcoded puppeteer-core paths that need updating. Look at your Jest config too - version 24.9.0 is pretty old and doesn’t play nice with newer puppeteer versions. Upgrade Jest to at least version 27 or 28. I fixed similar path issues by adding “type”: “module” to package.json and tweaking the Jest moduleNameMapper settings. Since PDF generation works fine in your main app, this is definitely a config problem, not a puppeteer bug.

Had the exact same headache when our CI pipeline broke after upgrading puppeteer. The problem is puppeteer completely changed how they export modules in v20+. Instead of wrestling with the upgrade, I created separate environments for testing and production. Kept puppeteer at 19.4.0 for tests using a test-specific package.json override, while production runs the latest version with proper CSS handling. You can do this with npm workspaces or conditionally import different puppeteer versions based on NODE_ENV. What really worked though was ditching puppeteer entirely for PDF generation and switching to playwright - way better CSS support and they don’t break their API every update. BTW, those module resolution errors? Clear your Jest cache directory manually, not just node_modules. Your Jest version is definitely part of the problem since it’s too old for the ESM support that newer puppeteer needs.

Switch to puppeteer-core instead of regular puppeteer - the import paths got messed up internally but puppeteer-core is way more stable. Your Jest version is super old too, I had the same problems until I upgraded to Jest 29. Quick workaround: throw --experimental-vm-modules in your test script, fixed my module resolution issues.