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.
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.