I’ve been struggling for about two weeks trying to get Puppeteer working in my AWS Lambda function. I keep running into the same error no matter what I try.
I’ve tested multiple approaches and different starter kits but nothing seems to work. I even tried downgrading Puppeteer to version 1.1.1 as some people suggested online.
Here’s the error I keep getting:
{
"errorMessage": "Failed to launch chrome! spawn /tmp/chromium_browser ENOENT\n\n\nTROUBLESHOOTING: [...]",
"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 current Lambda settings:
- Runtime: Node.js 8.10
- Handler: index.handler
- Memory: 3008 MB
- Timeout: 30 seconds
- Role: lambda_basic_execution
I’m using S3 upload because direct upload always times out. I’m working on Windows 7 and had to modify the package.json scripts to get it building properly.
Has anyone successfully deployed Puppeteer on Lambda recently? Any guidance would be really helpful.
check your lambda launch args - i hit the same issue when puppeteer wasn’t using --no-sandbox and --disable-setuid-sandbox flags. that /tmp/chromium_browser path looks off too. if you’re using layers, chrome should be in /opt/. try logging process.env to see what’s actually available at runtime.
That spawn ENOENT error happens because Lambda doesn’t have Chrome’s shared libraries. Hit this same problem last year - you need a Lambda layer with Chrome and its dependencies already installed. Either build your own or grab a public one like ServerlessChrome. Make sure your function can find the Chrome executable (usually /opt/chrome/chrome with layers). Your Windows 7 dev setup might be screwing up the packaging since Lambda runs Amazon Linux. I switched to Docker locally to avoid those cross-platform headaches. Memory looks fine but bump up the timeout for cold starts.
Had the same nightmare with Puppeteer on Lambda about six months ago. Lambda doesn’t include the Chrome dependencies Puppeteer needs, which is your main problem. What fixed it for me was switching to the chrome-aws-lambda package instead of trying to bundle Chrome myself. It’s got a pre-compiled Chromium binary that’s built specifically for Lambda. You’ll need to swap puppeteer for puppeteer-core and point it to the chrome-aws-lambda executable. Also, Node.js 8.10 is ancient now - upgrade to at least 14.x if you can. I had way fewer issues with newer versions. Your 3008 MB memory looks fine, but you might need to bump up the timeout depending on what you’re doing.