The serverless-esbuild bundler fails with Typeorm/Prisma
See original GitHub issueDescribe the bug
When trying to create a aws lambda with typescript and try to use some ORM like Typeorm and Prisma, whenever I write serverless deploy
or serverless-offline
, I get the same exact error.
To Reproduce
Clone this repo: https://github.com/joaocasarin/aws-lambda-typeorm-error
Run yarn install
to install dependencies and then either serverless deploy
or serverless offline
.
You will get the same exact error as in the below screenshot.
PS.: You will see the typeorm
version in the branch main
, and the prisma
version in the branch prisma
. Both executes as the description.
Expected behavior The lambda should execute as normal: create the lambda function, expect some input from user in a POST request body, and response with the created user.
Screenshots or Logs
Versions (please complete the following information):
- OS: Windows 10
- Serverless Framework Version: 3.14.0
- Serverless Plugin Version: 6.2.1
- serverless-esbuild version: ^1.26.2
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:22 (5 by maintainers)
Top GitHub Comments
I’m also having this issue, trying to use
Typeorm
with esbuild 😢Project compiles fine, until I import something from Typeorm into a handler.
I’ve got
typeorm
,pg
andpg-native
as externalsThe
sls:package
results in a weird crash loopbecause that library is written in a way where it’s expecting package.json to be at a specific spot in your directory.