Unable to import a module in Lambda

advertisements

I have a simple exports.js file and I have zipped the folder and upload it to Lambda but on run time it gives an error:

"errorMessage": "Cannot find module 'exports'",
"errorType": "Error",
"stackTrace":
[
"Function.Module._resolveFilename (module.js:338:15)",
"Function.Module._load (module.js:280:25)",
"Module.require (module.js:364:17)",
"require (module.js:380:17)"
]

Any help would be appreciated. Thanks


1.Name the file exports.js

2.Name the handler, within the file, exports.handler

exports.handler = function (event, context)
{
    var YourSkill = new YourSkill();
    YourSkill.execute(event, context);
}

3.Set the handler in the lambda config to exports.handler

4.Zip up only the contents of the folder, if you zip the folder as well it will not find your file.

5.Rename the zip file exports.zip