Hello all,
I’ve been struggling with this one for the last few days, scouring the forums but have been turning up blank.
I’m attempting to deploy my Functions to Netlify and the deployment completed successfully over there. However, when I attempt to hit the API endpoint I get the following error:
"message": "[error] evaluation failed with error: Cannot find module '/var/task/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Browser'"
This error does not exist for me locally. I have confirmed that Browser.ts
does exist in node_modules. I have attempted including package.json files individually in my functions. I have tried different node_bundler settings in my netlify.toml. I have removed other dependencies from the api/package.json
deps (chrome-aws-lambda) and the error has changed; then throwing an error for the newly missing dependency. This indicates to me that for some reason puppeteer-core is not being bundled, and I cannot figure out why.
Here’s my netlify.toml
:
[build]
command = "yarn rw deploy netlify"
publish = "web/dist"
functions = "api/dist/functions"
[dev]
framework = "redwoodjs"
targetPort = 8910
port = 8888
[[redirects]]
from = "/*"
to = "/200.html"
status = 200
[functions]
node_bundler = "esbuild"
external_node_modules = [
"chrome-aws-lambda",
"puppeteer-core",
"@magic-sdk/admin",
"@clerk/clerk-sdk-node/instance",
"firebase-admin",
"import-fresh"
]
I am not using the Netlify CLI to deploy. I am running yarn rw deploy netlify
to confirm the build, then pushing it to my repo and letting Netlify do the rest.
Here is my api/package.json
:
{
"name": "api",
"version": "0.0.0",
"private": true,
"devDependencies": {
"@types/puppeteer": "^5.4.6",
"puppeteer": "^19.2.2"
},
"dependencies": {
"@redwoodjs/api": "2.2.3",
"@redwoodjs/graphql-server": "2.2.3",
"chrome-aws-lambda": "^10.1.0",
"puppeteer-core": "^19.2.2"
}
}
I’m completely stuck at the moment. I’d rather not switch away from Netlify is possible. It seems to me that something in how Redwood is preparing the /dist
may be at fault, but I feel like I’m grasping at straws. Any guidance anyone could provide would be much appreciated.