Lambda Node18 type module, extension .mjs, results in ES error loading module

0

So, my package.json has type:module and the handler file extension is .mjs, so why am I getting this error?

ERROR (node:8) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

followed by this one:

2023-06-27T13:49:12.742Z 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:994:17)", " at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1032:21)", " at async start (file:///var/runtime/index.mjs:1195:23)", " at async file:///var/runtime/index.mjs:1201:1" ] }

Rick
질문됨 일 년 전1248회 조회
2개 답변
1
수락된 답변

It turned out that my serverless.yml deployment file was excluding the package.json file. Resolved.

Rick
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
0

Hi Rick,

Please take a look at this re:Post and see if it helps.

profile pictureAWS
전문가
답변함 일 년 전
  • Thanks, but not helpful, kinda the opposite of my error (as it knows type=module), but thanks anyway.

  • Checking further, as I remember that I have faced something similar. Hold on. :)

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠