This question already has an answer here:
- Node.js support for => (arrow function) 4 answers
I have code works in node.js v6.4: just two files, index.js:
// ------------ Index.js ------------
'use strict';
var Event = require('./models/event.js');
exports.handler = (event, context, callback) => {
console.log('done');
}
and event.js:
// ------------ Event.js ------------
class Event {
static get dynamoDBTableName() {
return
}
get hashValue() {
return
}
parseReference(reference) {
return
}
}
exports.Event = Event
when run index.handler
on AWS Lambda which use version node.js 4.3, it throws a error:
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 think it's something wrong with exports.Event = Event
,
Is there some trick to fix this.
I'm new to node.js.
Any help should be appreciated.
I think it's not SyntaxError with (event, context, callback) => { }
Because AWS Lambda sample code runs well with this Syntax: