I have a code that runs a lambda function and uses lambda layers. The code works as expected in AWS environment.
For simple lambdas i can run the lambda locally by providing the prerequisite ‘env’ file and running using the command
node --input-type=module -e "import {handler} from './index.js'; console.log(await handler(JSON.parse(fs.readFileSync('./event.json'))));";
For layers that has only simple logic and no nodemodules i tried creating a directory /opt and copied the contents of the layer over and it works as expected without any code changes.
But when I tried to run the code with lambda layers that has nodemodule references, locally it throws the error module not found
Is there a way this can be done ? Any references will be appreciated.
Thanks