I'm new in nodejs and aws lambda. I'm trying to create layer with common functions for my bunch of lambda functions.
In lambda handler the import of custom module has the following definition:
let commonService = require('@common/service');
The zip with the module file has the following structure:
nodejs
--node_modules
--@custom
--service
--index.js
--package.json
But I get the error:
"errorMessage": "Error: Cannot find module '@common/service'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
The @custom/service module package.json contains the following:
{
"name": "@common/service",
"version": "1.0.0",
"main": "index.js",
"license": "ISC",
"dependencies": {
/***
}
}
Thanks in advance!