How To Get Serverless to recognise "import" in Node JS

I have a simple Graph QL API which I want to upload to AWS Lambda, however, before getting anywhere near deployment…

However, I am struggling to even run the simple local query of:

serverless invoke local -f graphql -p query.json

I get the following error:

It seems that Serverless is unable to recognise imports from subdirectories in Node: apolloServer.js relies on imports from subdirectories such as utils, api, graphql etc…

It would be almost impossible to have all the code in the single apolloServer.js file.

Is there a way to make Serverless recognise imports from subdirectories in Node ?

Does it work when you deploy to actual Lamba e.g. is this a bug in serverless-local ?

Have you seen the docs on the package part of serverless.yml ? You can include any files in the deployment package, though we’d usually exclude whole “src” folders, and/or copy the bits needed to a “dist” and refer to them from there; YMMV.