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.

gefragt vor 8 Monaten481 Aufrufe
1 Antwort
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
EXPERTE
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen