My project's structure is next:
MyProject
layers
myLayer1
nodejs
node_modules
myLayer1
myExtension.js
lambda1
handler.js
lambda2
handler.js
jsconfig.json
myExtension.js
module.exports.myTest = () => {
return 'My extension test';
};
handler.js
const myext = require('myLayer1');
module.exports.handler = async (event) => {
return {
statusCode: 200,
body: JSON.stringify({
message: myext.myTest()
})
}};
When I deploy to AWS - things are working. But I'm unable to run/debug it on my local machine.
According to what I found the jsconfig.json file should help to map paths in this case, but VSCode/NodeJS ignore it whatever I wrote there (I tried to place it the MyProject root folder and within lambda folders).
I can run this lambdas locally if I change the 'require' within the handler.js to:
const myext = require('./layers/myLayer1/nodejs/node_modules/myLayer1');
which obviously breaks the code when I deploy it to AWS.