Cannot find module 'chrome-aws-lambda'

Hey guys!

I’m trying to create netlify function that can capture a screenshot with puppeteer.

Build & deploy works ok, but I see issue “Cannot find module ‘chrome-aws-lambda’”

chrome-aws-lambda & pupeeter-core are added as dependencies

const chromium = require("chrome-aws-lambda");
const puppeteer = require("puppeteer-core");

...
export const task = async () => {
  const executablePath = await chromium.executablePath;

  const browser = await puppeteer.launch({
    args: chromium.args,
    executablePath: executablePath,
    headless: chromium.headless,
  });

  const page = await browser.newPage();
...
// package.json
  "dependencies": {
    "chrome-aws-lambda": "^10.1.0",
    "puppeteer-core": "^10.4.0"
  }

Do you have any idea why?

Hey @lizzydoula

If build and deploy is working ok, where are you seeing the Cannot find module… issue?

@coelmay
I’m seeing it from function log

Sorry, I’ve mixed cjs & esm syntax. The solution is to remove esm “export” from my function. Or switch to esbuild.

1 Like