serverless / serverless-plugin-typescript

Serverless plugin for zero-config Typescript support
MIT License
781 stars 222 forks source link

Fix for only one function deploy #292

Open Marcosl14 opened 1 year ago

Marcosl14 commented 1 year ago

When I try to deploy only one function using layers, I got the next error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

And it is produced, because the function moveArtifacts() in the index.ts is looking for the service.layers[name].package.artifact which should be generated during the entire stack deploy.

So when deploying only one function with sls deploy --stage stage --region us-east-1 --verbose -f functionName, the code is trying to find the layer artifact which is generated when deploying the full stack (so... it doesn't exists at this point).

If I add the property artifact to the layer pointing to .serverless/libraries.zip I was able to deploy the function, but when I tried to deploy the stack, I recieved the next error: OperationalError: ENOENT: no such file or directory, because it was already not generated.

So, the fix is in the index file in the moveArtifacts() function.

image