Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Pupeeteer does not launch in latest version #9121

Closed
Thomblin opened this issue Oct 15, 2022 · 23 comments
Closed

[Bug]: Pupeeteer does not launch in latest version #9121

Thomblin opened this issue Oct 15, 2022 · 23 comments

Comments

@Thomblin
Copy link

Bug description

I am running pupeteer in WSL, ubuntu 20.04. I was able to run puppeteer v 18.1.0 by adding my chrome.exe from Windows to $PATH and launching puppeteer with

browser = await puppeteer.launch({ 
      executablePath: 'chrome.exe', 
      headless: true,
      args: ['--no-sandbox', '--disable-setuid-sandbox']
    });

However in the latest version (18.2.1) I get the error

FAIL src/App.e2e.test.js
● Test suite failed to run

Cannot find module 'puppeteer-core/internal/common/DeviceDescriptors.js' from 'node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js'

Require stack:
  node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js
  src/App.e2e.test.js

  at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
  at Object.<anonymous> (node_modules/puppeteer/src/puppeteer.ts:18:1)

Puppeteer version

18.2.1

Node.js version

16.17.0

npm version

8.19.2

What operating system are you seeing the problem on?

Windows

Relevant log output

No response

@Thomblin Thomblin added the bug label Oct 15, 2022
@jrandolf-2
Copy link
Contributor

Could you try the latest version?

@Thomblin
Copy link
Author

Thanks for the hint. I upgraded to 19.0.0 and get almost the same error:

FAIL src/App.e2e.test.js
● Test suite failed to run

Cannot find module 'puppeteer-core/internal/common/Device.js' from 'node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js'

Require stack:
  node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js
  src/App.e2e.test.js

  at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
  at Object.<anonymous> (node_modules/puppeteer/src/puppeteer.ts:18:1)

@jrandolf-2
Copy link
Contributor

Ah, jest-resolver... my old nemesis. Your jest version is too old. It needs exports resolution that was introduced in Node 12. I believe Jest versions >= 28 will work.

@Thomblin
Copy link
Author

Not sure, if that is possible. I am using react-script and the latest version 5.0.1 comes along with "jest": "^27.4.3", if I see that correctly. So far I was not able to force the usage of v29. I am open for ideas how to upgrade or how to replace jest with something else

@petrvecera
Copy link

Hm we are running into the same problem.

@integration-tests/spartacus: FAIL test/spartacus-integration.test.js
@integration-tests/spartacus:   ● Test suite failed to run
@integration-tests/spartacus:     Cannot find module 'puppeteer-core/internal/common/Device.js' from '../../node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js'
@integration-tests/spartacus:     Require stack:
@integration-tests/spartacus:       /home/runner/work/xdn/xdn/node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js
@integration-tests/spartacus:       test/spartacus-integration.test.js
@integration-tests/spartacus:       at Resolver.resolveModule (../../node_modules/jest-resolve/build/index.js:306:11)
@integration-tests/spartacus:       at Object.<anonymous> (../../node_modules/puppeteer/src/puppeteer.ts:18:1)

Version 18.2.1 is OK. It started happening in the upgrade to version 19.x. No Idea why.
We running this in GitHub Actions - ubuntu latest.

We are gonna stick with version 18.x for now.

@lysender
Copy link

lysender commented Nov 12, 2022

We are using nestjs but we're not using the latest nestjs version yet. Luckily, jest 28.1.3 works and all our e2e tests passed.

I just copied the jest versions from the latest nestjs app to our current app.

"@types/jest": "28.1.8",
"jest": "28.1.3",
"ts-jest": "28.0.8",

@hitesh22b
Copy link

hitesh22b commented Nov 23, 2022

I am facing the same issue even after upgrading jest to the latest version

"puppeteer": "^19.2.2",
 "@types/jest": "^29.2.3",
 "@types/jest": "^29.2.3",
"jest": "^29.3.1"

@viditganpi
Copy link

Any resolution for this?

@white-wolf97
Copy link

white-wolf97 commented Nov 30, 2022

Hi, why is it closed? I think the problem is not resolved, it is happenning to me right now.
I have react-scripts 5.0.1 too, with puppeteer 19.3.0

@Strato
Copy link

Strato commented Dec 5, 2022

I just had the same problem and upgrading Jest from v27 to v29 worked for me, as expected.

So you either have to upgrade Jest to v28 if you can, or downgrade Puppeteer to v18.1.

@omergal99
Copy link

npm install puppeteer@18.1.0

@TamilSelvanKumaravel
Copy link

npm install puppeteer@18.1.0

It's working

@Sineaggi
Copy link

Sineaggi commented Feb 7, 2023

In our case, a previous version of jest was being invoked by our test runner. I was able to debug that via jest's showConfig. After updating that dependency's version of jest we were set.

@juanmirocks
Copy link

I get a similar error with puppeteer@19.7.5:
Error: Could not resolve module "puppeteer-core/internal/puppeteer-core.js" (same error as in: Studiosity/grover#182)

In my case, I'm not using jest. I'm calling puppeteer through a parcel plugin (parcel@2.8.3).

Rolling back to:

  • npm install puppeteer@18.1.0 ✅ works
  • npm install puppeteer@18.2.x ❌ fails with a similar (though not equal) error:
    Error: Could not resolve module "puppeteer-core/internal/common/DeviceDescriptors.js"

Note that puppeteer@18.2.0 (#9023) (f42336c) separated puppeteer and puppeteer-core. Likely a bug was introduced; not directly related to jest or parcel or any other library.

In my humble opinion, this issue is still open.

@HerRA17
Copy link

HerRA17 commented May 9, 2023

Hi there,
so for an exercise that I am following I am facing the bug mentioned and this is the response:

Cannot find module 'puppeteer-core/internal/puppeteer-core.js' from 'node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js'

    Require stack:
      node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js
      src/test/EndToEnd.test.js

      at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
      at Object.<anonymous> (node_modules/puppeteer/src/puppeteer.ts:19:1)

I have puppeteer: ^19.4.0, I tried with 18.1.0 as suggested but received a no longer supported.
This are other dependencies that we are using:
"@wojtekmaj/enzyme-adapter-react-17": "^0.8.0",
"enzyme": "^3.11.0",
"jest-cucumber": "^3.0.1"

@turbolego
Copy link

npm install puppeteer@18.1.0 works for me too.

With puppeteer@20.5.0 i got the error [ERR_PACKAGE_PATH_NOT_EXPORTED]

Now i get: Downloading Chromium r1045629 - 189.9 Mb [===== ] 26% 16.9s

@AS360
Copy link

AS360 commented Jul 6, 2023

#_Facing This Issue in in server side(after deploy) - 'puppeteer' Working in local machine properly.
Any Solution ??

Error: Failed to launch the browser process!
/home/abp/.cache/puppeteer/chrome/linux-1108766/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

TROUBLESHOOTING: https://pptr.dev/troubleshooting

at Interface.onClose (/home/abp/abpwedcrmapis-manager/abpwedcrmapis-manager/node_modules/@puppeteer/browsers/lib/cjs/launch.js:262:24)

at Interface.emit (node:events:525:35)
at Interface.emit (node:domain:489:12)
at Interface.close (node:readline:590:8)
at Socket.onend (node:readline:280:10)
at Socket.emit (node:events:525:35)
at Socket.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

@pigping88
Copy link

pigping88 commented Sep 4, 2023

node 18 npm 9, puppeteer 21
error:
the dependency can not find

  • puppeteer-core/internal/node/PuppeteerNode.js in ./node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js * puppeteer-core/internal/puppeteer-core.js in ./node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js

@townxelliot
Copy link

townxelliot commented Nov 8, 2023

I'm not sure why this is closed, as this is still a problem on Puppeteer > 18.1.0 (which is out of support) where you are using ESM module loading, e.g. with Puppeteer 18.2.1:

% node -r esm
Welcome to Node.js v20.5.1.
Type ".help" for more information.
> require('puppeteer');
/Users/elliot.smith/projects/opg-pdf-service/node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js:1
Uncaught Error: Cannot find module 'puppeteer-core/internal/puppeteer-core.js'
Require stack:
- /Users/elliot.smith/projects/opg-pdf-service/node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js
- <repl>
    at Object.<anonymous> (/Users/elliot.smith/projects/opg-pdf-service/node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js:33:14)
    at Generator.next (<anonymous>) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/elliot.smith/projects/opg-pdf-service/node_modules/puppeteer/lib/cjs/puppeteer/puppeteer.js',
    '<repl>'
  ]
}
> 

The problem appears to be the -r esm flag, as this works fine for me without it:

% node       
Welcome to Node.js v20.5.1.
Type ".help" for more information.
> require('puppeteer');
{
  connect: [Function: bound bound connect],
  defaultArgs: [Function: bound defaultArgs],
  executablePath: [Function: bound executablePath],
  launch: [Function: bound launch],
  trimCache: [Function: bound trimCache] AsyncFunction,
  WEB_PERMISSION_TO_PROTOCOL_PERMISSION: [Getter],
...

We are using jest, but our version is up to date (29.7.0), and I'm not sure why that would be involved in a straight require('puppeteer'); call anyway.

@twointo2
Copy link

twointo2 commented Feb 9, 2024

Hi!
Is there any update on this issue? I am still getting Cannot find module 'puppeteer-core/internal/puppeteer-core.js' on the following config:

"esm": "^3.2.25"
"puppeteer": "^22.0.0"

@townxelliot were you able to find any solution for this?

@bradytrudeau
Copy link

Has anyone figured out how to resolve this?

@talhakhadim
Copy link

For me the issue is fixed by upgrading my jest to v:29.7.0

@abnerAlexis
Copy link

I am also having the same issue.
I upgraded jest to v29.7.0
node version: 20.9.0
OS: Mac
I tried so many versions (22s to 18.1.0) of puppeteer but none worked.
Any suggestion would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests