serverless-plugin-typescript
serverless-plugin-typescript copied to clipboard
Doesn't support new Docker `image` syntax
As per https://www.serverless.com/blog/container-support-for-lambda, you can now use the image
property in function instead of a handler
.
Error
Type Error ---------------------------------------------
TypeError: Cannot read property 'split' of undefined
is thrown at https://github.com/prisma-labs/serverless-plugin-typescript/blob/master/src/typescript.ts#L51 because it expects a handler
property to be defined.
Required if you have (like I do) a mix of typescript handlers and Docker images in the same application.
If you've found this issue from a search engine, a (less-than-ideal) solution I've used for deployment is to create a separate serverless.docker.yml
file with your Docker based deployments, and run serverless deploy -c serverless.docker.yml
Sorry, I found this issue by search... and I was doing, presumably, exactly what you said, yet, this not working for me:
Test based on example (which is awfully outdated).
Dockerfile
:
FROM public.ecr.aws/lambda/nodejs:14
COPY handler.ts ./
CMD ["handler.hello"]
serverlessD.yml
:
service: serverless-example
frameworkVersion: "2 || 3"
plugins:
- serverless-plugin-typescript
provider:
name: aws
# runtime: nodejs14.x
ecr:
images:
appimage:
path: ./
region: eu-west-2
lambdaHashingVersion: 20201221
functions:
hello:
# handler: handler.hello
image:
name: appimage
events:
- http:
path: hello
method: get
Then:
$ sls deploy -s test -c serverlessD.yml
Serverless: Compiling with Typescript...
Type Error ----------------------------------------------
TypeError: Cannot read property 'split' of undefined
...
What am I doing wrong please?
still happening anyone have work around?
It does look like the plugin is looking for handler
property, but for instance with function that is mapped to docker image does not have this property.
Adding handler
property with image
gets error on serverless deploy.
Add a specific runtime
for your function that use the image. If you set it to python3.9
for example, the typescript plugin won't run against it. You may be able to set this to an empty string, but my container does actually use python 3.9
Any luck resolving this issue running into it myself now, switching from a handler to image.
Has any progress been made on this? This bug makes it impossible to use ECR images with typescript lambdas in serverless.
Trying in 2024 and the error seems to still be present
I have the same error here when defining a function that uses image
instead of handler
.
@douglasgsouza I was able to deploy my app by removing the plugin from my project and building it with tsc