I am using NodeJs 6.10.2. I am using 2 files
index.js
var operation = require('./Handler/opHandler').opHandler;
var lambdaHandler = function () {
var o = new operation();
o.deleteMessage();
}
exports.lambdaHandler = function(event, context, callback) {
handleSQSMessages(context, callback);
};
opHandler.js
opHandler = function() {
this.db = '';
}
opHandler.prototype.deleteMessage = function (receiptHandle, callback) {
// My code here
// this.db = 'new val';
}
exports.opHandler = opHandler;
when run index.lambdaHandler on AWS Lambda with NodeJs 6.10, following error occurs
Syntax error in module 'index': SyntaxError
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/task/index.js:16:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
I have googled and found similar issue here but according to it above code should work in NodeJs 6.10