Serverless Function looking for node_modules inside function directory instead of node_modules directory

503 Views Asked by At

I have created a serverless function for generating PDF, and I am using chrome-aws-lambda with puppeteer-core. But when I call chromium.puppeteer.launch, it throws following error:

Cannot find module '/path/to/project/.esbuild/.build/src/functions/generatePdf/puppeteer/lib/Browser'

chrome-aws-lambda trying to look for puppeteer in directory of generatePdf (my function). However looking into source of chrome-aws-lambda, I found that it wants to look in relative directory, where chrome-aws-lambda module resides as following:

enter image description here

So, it wants to load puppeteer libs from same directory, as per source (from github)

enter image description here

Currently, I have no idea, why it is showing such behavior, and after a lot of scavenging, online I couldn't find any fruitful solution.

0

There are 0 best solutions below