2 Answers
- Newest
- Most votes
- Most comments
0
Please check the following:
- Your node,js version is 16.x
- Your index file has an extension of mjs as you are using ES module syntax - https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html
answered 2 years ago
0
Thanks Mike,
regarding 1): Yes, thats correct regarding 2): It has indeed been a .js file (this is the default index after selecting 16.x though...)
I've changed the name to index.mjs but the test still throws an error:
answered 2 years ago
Relevant content
- asked 3 years ago
- asked 3 years ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago
Thanks Mike,
regarding 1): Yes, thats correct regarding 2): It has indeed been a .js file (this is the default index after selecting 16.x though...)
I've changed the name to index.mjs but the test still throws an error:
Response { "errorType": "Runtime.UserCodeSyntaxError", "errorMessage": "SyntaxError: Unexpected token 'export'", "trace": [ "Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token 'export'", " at _loadUserApp (file:///var/runtime/index.mjs:993:17)", " at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1031:21)", " at async start (file:///var/runtime/index.mjs:1194:23)", " at async file:///var/runtime/index.mjs:1200:1" ] }
Function Logs 2023-03-21T12:45:45.106Z undefined ERROR Uncaught Exception {"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token 'export'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token 'export'"," at _loadUserApp (file:///var/runtime/index.mjs:993:17)"," at async Object.UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1031:21)"," at async start (file:///var/runtime/index.mjs:1194:23)"," at async file:///var/runtime/index.mjs:1200:1"]} 2023-03-21T12:47:11.303Z undefined ERROR Uncaught Exception {"errorType":"Runtime.UserCodeSyntaxError","errorMessage":"SyntaxError: Unexpected token 'export'","stack":["Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token 'export'"," at