Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"require is not defined in ES module scope, you can use import instead" #141

Open
HughMorris01 opened this issue Mar 5, 2023 · 4 comments

Comments

@HughMorris01
Copy link

2023-03-05T05:18:16.556Z undefined ERROR Uncaught Exception
{
"errorType": "ReferenceError",
"errorMessage": "require is not defined in ES module scope, you can use import instead",
"stack": [
"ReferenceError: require is not defined in ES module scope, you can use import instead",
" at file:///var/task/index.mjs:3:11",
" at ModuleJob.run (node:internal/modules/esm/module_job:194:25)"
]
}

I continue to get this error from the very beginning of the script and I've tried changing it to import and the code breaks even further. I'm sure that this is somehow related to my configurations but I have it set on node.js 18.x and I don't see a whole lot else I could change to get this to work. Please help.....

@sonykphilip
Copy link

Change the index.mjs to index.js, and runtime to node 16.x. That should make it work. However, I just moved to using https://github.com/adam-fowler/ses-forwarder-lambda

@xml
Copy link

xml commented May 1, 2023

Either I goofed, or changing index.js didn't work for me. However, making it index.cjs (CommonJS module extension) seems to have done the trick. No other syntax changes required, as yet. (Although I'm now debugging other things...)

@hophamlam
Copy link

Change the index.mjs to index.js, and runtime to node 16.x. That should make it work. However, I just moved to using https://github.com/adam-fowler/ses-forwarder-lambda

This works for me, change index.mjs to index.js, and runtime to node 16.x 🔥🔥🔥

@clicktechnology
Copy link

Change the index.mjs to index.js, and runtime to node 16.x. That should make it work. However, I just moved to using https://github.com/adam-fowler/ses-forwarder-lambda

Same. Works properly now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants