You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can someone help me? I'm using SAM to deploy a lambda function that uses puppeteer to generate PDF files but, running it locally or deploying it gives me the same error, this one bellow:
Error: The input directory "/var/bin" does not exist. at Function.executablePath (/AppData/Local/Temp/tmpsa2mj74m/node_modules/@sparticuz/chromium/build/index.js:229:19) at Runtime.ByA (/AppData/Local/Temp/tmpsa2mj74m/app.ts:39:44) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)
Outputs:
GeradorPdfApi:
Description: "API Gateway endpoint URL for Prod stage for PDF generation"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/gerar-pdf/"
GeradorPdfFunction:
Description: "Gerador PDF Lambda Function ARN"
Value: !GetAtt GeradorPdfFunction.Arn
GeradorPdfFunctionIamRole:
Description: "Implicit IAM Role created for pdf generation function"
Value: !GetAtt GeradorPdfFunctionRole.Arn
Second this is my lambdaHandler:
`import { ProxyHandler } from 'aws-lambda';
import { PdfGeneratorDTO } from './@types/pdfGenerator';
import { gerarPdf } from './gerador/geradorPdf';
import chromium from '@sparticuz/chromium';
import puppeteer from 'puppeteer-core';
And also tried some help from google, chat gpt, issues from github, etc. None helped me to solve my problem. Can someone exploin what am I doing wrong here and how solve that?
The text was updated successfully, but these errors were encountered:
that function does it best to 'find' the chromium.br file that contains chromium. If you get that error it means that it was unable to find the file. Make sure of a few things. 1) That the package is included in external dependencies (#24 (comment)) and 2) You may need to directly specify where the file is. (This would change from user to user)
Can someone help me? I'm using SAM to deploy a lambda function that uses puppeteer to generate PDF files but, running it locally or deploying it gives me the same error, this one bellow:
Error: The input directory "/var/bin" does not exist. at Function.executablePath (/AppData/Local/Temp/tmpsa2mj74m/node_modules/@sparticuz/chromium/build/index.js:229:19) at Runtime.ByA (/AppData/Local/Temp/tmpsa2mj74m/app.ts:39:44) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)
First of all this is my current template.yaml:
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Description: >
gerador-pdf-lambda
Sample SAM Template for gerador-pdf-lambda
Globals:
Function:
Timeout: 30
MemorySize: 512
Resources:
ChromiumLayer:
Type: AWS::Serverless::LayerVersion
Properties:
Description: Chromium with Node.js integration for AWS Lambda
ContentUri: layers/chromium
CompatibleRuntimes:
- &nodejsRuntime nodejs22.x
instances
CompatibleArchitectures:
- &chromiumArch x86_64
RetentionPolicy: Delete
Metadata:
BuildMethod: *nodejsRuntime
BuildArchitecture: *chromiumArch
GeradorPdfFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: src/
Handler: app.lambdaHandler
Runtime: nodejs22.x
Architectures:
- x86_64
Events:
GerarPdf:
Type: Api
Properties:
Path: /gerar-pdf
Method: get
Metadata:
BuildMethod: esbuild
BuildProperties:
Minify: true
Target: "es2020"
Sourcemap: true
EntryPoints:
- app.ts
Outputs:
GeradorPdfApi:
Description: "API Gateway endpoint URL for Prod stage for PDF generation"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/gerar-pdf/"
GeradorPdfFunction:
Description: "Gerador PDF Lambda Function ARN"
Value: !GetAtt GeradorPdfFunction.Arn
GeradorPdfFunctionIamRole:
Description: "Implicit IAM Role created for pdf generation function"
Value: !GetAtt GeradorPdfFunctionRole.Arn
Second this is my lambdaHandler:
`import { ProxyHandler } from 'aws-lambda';
import { PdfGeneratorDTO } from './@types/pdfGenerator';
import { gerarPdf } from './gerador/geradorPdf';
import chromium from '@sparticuz/chromium';
import puppeteer from 'puppeteer-core';
export const lambdaHandler: ProxyHandler = async (event, context, callback) => {
if (!event.body) {
return {
statusCode: 400,
body: JSON.stringify({
message: 'missing body',
}),
};
}
};
`
Third these are my folders has this pattern:
And, these are the package.json files dependencies
`layers/chromium package:
"dependencies": {
"@sparticuz/chromium": "^131.0.1"
}
`
`src package:
"dependencies": {
"@sparticuz/chromium": "^131.0.1",
"dayjs": "^1.11.13",
"esbuild": "^0.14.14",
"puppeteer-core": "^24.0.0",
"qrcode": "^1.5.4"
},
"devDependencies": {
"@types/aws-lambda": "^8.10.92",
"@types/node": "^20.5.7",
"@types/qrcode": "^1.5.5",
"@typescript-eslint/eslint-plugin": "^5.10.2",
"@typescript-eslint/parser": "^5.10.2",
"eslint": "^8.8.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.5.1",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
}
`
Finally
I followed some instructions from this page: https://github.com/Sparticuz/chromium/tree/master/examples/aws-sam
And also tried some help from google, chat gpt, issues from github, etc. None helped me to solve my problem. Can someone exploin what am I doing wrong here and how solve that?
The text was updated successfully, but these errors were encountered: