Link to chapter - https://serverless-stack.com/chapters/share-code-between-services.html
I have tried to share some code in a libs folder outside of the folder where my serverless.yml file is. It works perfectly with
sls invoke local but invocations fail once deployed : do I have to specify something in particular in my config so that my libs folder is packaged and included ?
Hmm when you say the invocation fails, whats the command that is failing?
sls invoke --function functionName
I have found what was going wrong :
does not work : handler needs to be in the same subtree as the
Glad you figured it out.
Thank you for the article, however it seems that something is missing. I am trying to share code in an external folder, but when I deploy it to lambda I get an error that it cannot find the library.
here is the require in the handler.js file
const errors = require('../../utils/errors/errors');
but when I run the code on lambda it says
Cannot find module '../../utils/errors/errors'
I assume, because you mentioned earlier in the article, that you are using
serverless-bundle however, in this section you don’t mention it, or how you set it up.
serverless-bundle, and the error has changed to
Cannot set property 'getError' of undefined
that is the name of the function I am calling in the error util. Do you know if
serverless-bundle is moving the file, so I need to use a different path in the require?
Anyways there seems to be more complexity to including shared libraries than the original article indicates.