Error: Cannot find module '/var/task/src/app/lambda/puppeteer/lib/Browser
See original GitHub issueEnvironment
- puppeteer-core: “16.0.0”
- @sparticuz/chrome-aws-lambda: “16.0.0”
- OS: Mac
- Node.js Version: 16.x
- Lambda / GCF Runtime:
nodejs16.x
Working great locally. I’ve created a lambda layer via:
git clone --depth=1 https://github.com/Sparticuz/chrome-aws-lambda.git
cd chrome-aws-lambda
make chrome_aws_lambda.zip
Uploaded the zip manually to a new layer via AWS console, and attached it (via serverless config below) to my lambda
I’m excluding the @sparticuz/**
module during package/bundle so my lambda uses the layer version.
plugins:
- serverless-esbuild
package:
individually: true
patterns:
- '!node_modules/@sparticuz/**'
custom:
esbuild:
platform: node
bundle: true
external: ['knex', 'pg']
functions:
api:
handler: src/app/lambda/api.handler
url: true
layers:
- arn:aws:lambda:eu-west-2:173514141284:layer:chrome-aws-lambda:2
and my function code is:
import chromium from '@sparticuz/chrome-aws-lambda'
browser = await chromium.puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: true,
ignoreHTTPSErrors: true
})
but running it on lambda gives me a 500 with:
Error: Cannot find module '/var/task/src/app/lambda/puppeteer/lib/Browser'\nRequire stack:\n- /var/task/src/app/lambda/api.js\n- /var/runtime/index.mjs
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
In my case, I got it like this "Module not found: Error: Can't resolve 'react-icons/fa' in 'C:\Users\user\Desktop\Projects\Address Locator\ ...
Read more >ServiceNow Community servicenow community
I am trying to setup the CLI for component development and get the infamous error "keytar module" not found. Can someone tell me...
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >Error: Cannot find module 'bcrypto.node' · Issue #127 - GitHub
i got some error here D:\DataGalang\test-cepot\hs-airdrop\node_modules\loady\lib\loady.js:156 throw err; ^ Error: Cannot find module ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
OK finally got it working without bundling it in the lambda, but loading it from the layer;
the build/index.js path is required for me because I’m using ESM and Lambda layers don’t support native ESM loading yet
OK the package exclude idea wasn’t the solution, using esbuild you need to mark this entire lib as external:
EDIT: Spoke too soon, this bundles the binaries which makes for a huge package. I’ll keep trying to get it to use the lambda layer version