I am currently working on an express app (API) which I now want to convert to use the serverless framework so I can deploy on AWS Lambda. I have done this before and did not have too many issues.
I have made the few code changes that need to be made and I can build and run the server using sls offline no problem, but as soon as I make a call to the API it crashes with a dependency error like the following:
Error: Dynamic require of "fs" is not supported
This error pointed to the dotenv package which sure enough had a "require('fs')" line in it. I commented out my import of the dotenv package just to see what would happen and called the API again. I got another error, but this time it was about the "path" package.
Error: Dynamic require of "path" is not supported
So this is obviously not an issue with just one package, it seems to be a compatibility issue between the serverless framework and my express app. The only real difference between this express app and the other one I made which works fine with serverless is that this new one is using typescript. Anyone with experience in express and serverless have any idea what could be causing the issue? Thanks in advance.