Setting up Puppeteer in AWS Lambda Function

I’ve been struggling for about 2 weeks trying to get Puppeteer working in AWS Lambda but keep running into issues.

I’ve tested multiple approaches and starter kits but none seem to work. I’m working on Windows 7 and had to modify the package.json scripts section to get the build working properly. I’ve experimented with different Puppeteer versions and Chromium builds, including trying version 1.1.1 as suggested by other developers.

The main error I keep getting is:

{
    "errorMessage": "Failed to launch chrome! spawn /tmp/browser_shell ENOENT\n\n\nTROUBLESHOting: [...]",
    "errorType": "Error",
    "stackTrace": [
        "",
        "onClose (/var/task/node_modules/puppeteer/lib/Launcher.js:299:14)",
        "ChildProcess.helper.addEventListener.error (/var/task/node_modules/puppeteer/lib/Launcher.js:290:64)",
        "emitOne (events.js:116:13)",
        "ChildProcess.emit (events.js:211:7)",
        "Process.ChildProcess._handle.onexit (internal/child_process.js:196:12)"
    ]
}

My Lambda configuration:

  • Runtime: Node.js 8.10
  • Handler: index.handler
  • Role: lambda_basic_execution (also tried custom role with full Lambda and S3 access)
  • Timeout: 30 seconds
  • Memory: 3008 MB
  • Deploy method: S3 upload (UI and CLI both timeout)

Has anyone successfully deployed Puppeteer on Lambda and can share some guidance on what might be going wrong?

Your Windows 7 dev environment might be causing the deployment issues. I hit similar problems last year - the packaging process was corrupting binaries during zip creation. What fixed it for me was switching to serverless framework with their puppeteer plugin. It handles all the chromium bundling mess automatically. Also check your node_modules size after bundling - mine hit the 250MB limit and caused silent failures. That ENOENT error usually means Lambda can’t find the chrome binary, but sometimes it’s actually a permissions issue with the extracted files in /tmp.

Had the same Chrome path issue in Lambda about 6 months back. Lambda can’t find the Chrome binary where it expects it. I fixed it by bundling a pre-built Chromium binary made for Amazon Linux with my deployment package. Then I pointed Puppeteer to it using executablePath. Don’t forget the Lambda flags: --no-sandbox and --disable-setuid-sandbox. Your 3008MB memory looks fine, but bump the timeout to 60 seconds for testing - cold starts can really slow things down.

yep, windows 7 can be a pain! switching to puppeteer-core with chrome-aws-lambda made my life way easier too. saves you from dealing with chromium packaging, and it just works on lambda without all the headaches. give it a shot!