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.

asked 8 months ago452 views
1 Answer
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
EXPERT
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions