Error with imports when trying to upload code to Lambda Function

0

I am working on trying to deploy my code to an aws lambda function via a .zip file and I keep getting the following error when testing:

"errorType": "Error", "errorMessage": "require() of ES Module /var/task/index.js from /var/runtime/index.mjs not supported.\nInstead change the require of index.js in /var/runtime/index.mjs to a dynamic import() which is available in all CommonJS modules.", "trace": [ "Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/index.js from /var/runtime/index.mjs not supported."

In my package.json I have "type":"module" declared, and I am not using any 'require' imports in any of my files, so I am pretty confused on why this is happening.

If anyone could shed some light on this, that would be great!

Thank you in advance.

已提问 8 个月前481 查看次数
1 回答
0

Hello.

It seems that the package version may be the cause, so you may want to check the package you are using.
https://stackoverflow.com/questions/70541068/instead-change-the-require-of-index-js-to-a-dynamic-import-which-is-available

profile picture
专家
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则