Issue Description: What’s happening?
Good morning, I am trying to do a simple webhook to send emails. The problem is that after deploying and trying to fetch my webhook function I get the following error “module not found”. Testing locally everything works perfectly the problem only happens after deploy.
my package.json
{
"name": "test",
"version": "1.0.0",
"description": "8base Custom Logic",
"dependencies": {
"@sendgrid/mail": "^7.1.1",
"chrome-aws-lambda": "^3.1.1",
"dotenv": "^8.2.0",
"graphql-request": "^1.6.0",
"path": "^0.12.7",
"pug": "^2.0.4",
"puppeteer": "^3.1.0"
}
}
handler.js
import mailer from '../../../shared/mailer';
import sengridTemplates from '../../../shared/sengrind-templates';
import pdfTemplate from './pug-template';
require('puppeteer');
const chromium = require('chrome-aws-lambda');
const pug = require('pug');
export default async (event) => {
let browser = null;
try {
const { form, calculator } = event.data;
// client message
const pugTemplate = pug.compile(pdfTemplate);
const html = pugTemplate(calculator);
browser = await chromium.puppeteer.launch({
headless: true,
});
const page = await browser.newPage();
page.setContent(html);
const pdf = await page.pdf();
const clientMessage = {
to: form.email,
from: 'no-reply@Test.com',
subject: 'Test subject',
// setting dynamic template
templateId: sengridTemplates['calculator-contact'],
attachments: [
{
content: pdf.toString('base64'),
filename: 'attachment.pdf',
type: 'application/pdf',
disposition: 'attachment',
},
],
};
// cobuildlab team message
const teamMessage = {
to: 'palokesea3@gmail.com',
from: 'no-reply@Test.com',
subject: 'Test',
templateId: sengridTemplates['calculator-team'],
dynamic_template_data: {
name: form.name,
email: form.email,
message: form.message,
},
};
await mailer.send(teamMessage);
await mailer.send(clientMessage);
return {
statusCode: 200,
body: JSON.stringify({
result: 'all ok',
}),
};
} catch (error) {
// console.error(error)
if (error.response) {
return {
statusCode: 400,
body: JSON.stringify({
result: error.response.body,
}),
};
}
return {
statusCode: 400,
body: JSON.stringify({
result: error.code || error,
}),
};
} finally {
if (browser !== null) {
await browser.close();
}
}
};
Reproduce the Issue: What steps can someone take to replicate the problem?
after make deploy i run 8base invoke mail -m request
o try make a request with postman
Expected Behavior: What did you expect to happen?
Result:
{
"statusCode": 200,
"body": "{\"result\":\"all ok\"}"
}
Actual Behavior: What actually happened?
Server response 500 internal server error, **Cannot find module 'puppeteer'**
update
If I remove puppeteer from the code everything works fine, it seems that the size of the package is causing a problem