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] Cannot find module ...node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser' #293

Open
hobik opened this issue May 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hobik
Copy link

hobik commented May 15, 2023

Hello I'm trying to use puppeter with chrome-aws-lambda on Glitch.

Firstly I add this line in package.json file.

 "engines": {
    "node": "16.x"
  },
  "dependencies": {
    "chrome-aws-lambda": "^10.1.0",
    "dotenv": "^16.0.3",
    "nodemon": "^2.0.22",
    "puppeteer": "^20.1.2",
    "puppeteer-core": "^20.2.0",
    "request": "^2.88.2"
  }

I install these packages with npm install.

I have these source codes:

try{
const browser = await chromium.puppeteer.launch({
    args: [...chromium.args, "--hide-scrollbars", "--disable-web-security"],
    defaultViewport: chromium.defaultViewport,
    executablePath: await chromium.executablePath,
    headless: true,
    ignoreHTTPSErrors: true,
  })
      const page = await browser.newPage();
} catch (e) {
      console.log("ERROR =>", e);
    }

When I run this code I get this error:

ERROR => Error: Cannot find module '/rbd/pnpm-volume/eb105cb7-194c-4b68-b434-9102fa0ffea3/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:960:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:953:15)
    at resolveExports (node:internal/modules/cjs/loader:482:14)
    at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/rbd/pnpm-volume/eb105cb7-194c-4b68-b434-9102fa0ffea3/node_modules/chrome-aws-lambda/build/puppeteer/lib/Browser.js:8:13)
    at Module._compile (node:internal/modules/cjs/loader:1103:14) {
  code: 'MODULE_NOT_FOUND',
  path: '/rbd/pnpm-volume/eb105cb7-194c-4b68-b434-9102fa0ffea3/node_modules/puppeteer-core/package.json'

How can I solve this problem ?

@hobik hobik added the bug Something isn't working label May 15, 2023
@HakimBoulestin
Copy link

I would suggest moving to another library as this library does not seem to be supported anymore:
https://pptr.dev/chromium-support
https://www.npmjs.com/package/@sparticuz/chromium?activeTab=versions

@Lissy93
Copy link

Lissy93 commented Jul 22, 2023

You can fix this by using the puppeteer directly, so in your code just update it like so:

- const browser = await chromium.puppeteer.launch({
+ const browser = await puppeteer.launch({

And don't forget to import puppeteer from puppeteer-core ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants