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

Node.js 20 support #149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

OscarSaharoy
Copy link

Hi, thanks so much for this project :) I have just set this up in node 20 and got it working with these changes so I thought people might find it useful. I can make changes + additions if it would be helpful but just putting this PR in for reference!

@jchan172
Copy link

jchan172 commented Apr 5, 2024

This doesn't work. I tried this in Lambda and got this:

2024-04-05T06:10:36.182Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "Runtime.UserCodeSyntaxError",
    "errorMessage": "SyntaxError: Cannot use import statement outside a module",
    "stack": [
        "Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1084:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
        "    at async start (file:///var/runtime/index.mjs:1282:23)",
        "    at async file:///var/runtime/index.mjs:1288:1"
    ]
}

@OscarSaharoy
Copy link
Author

This doesn't work. I tried this in Lambda and got this:

2024-04-05T06:10:36.182Z	undefined	ERROR	Uncaught Exception 	
{
    "errorType": "Runtime.UserCodeSyntaxError",
    "errorMessage": "SyntaxError: Cannot use import statement outside a module",
    "stack": [
        "Runtime.UserCodeSyntaxError: SyntaxError: Cannot use import statement outside a module",
        "    at _loadUserApp (file:///var/runtime/index.mjs:1084:17)",
        "    at async UserFunction.js.module.exports.load (file:///var/runtime/index.mjs:1119:21)",
        "    at async start (file:///var/runtime/index.mjs:1282:23)",
        "    at async file:///var/runtime/index.mjs:1288:1"
    ]
}

Ah thanks for giving it a go anyway, I think its working for me though, I made a new node.js version 20.x Lambda function and copied the code from the index.js file in this branch into index.mjs in the lambda code editor. And when I clicked save and then deploy and test it seemed to work, and I didnt get that error?

@Aldekein
Copy link

I just tried this code with Node 20: it works great! I created one index.mjs file in the root of new Lambda for the code.

Copy link

@Aldekein Aldekein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works with Node v20 in AWS Lambda.

@Andrey-Svetlichny
Copy link

This works with Node v20 in AWS Lambda.
For people who get an error:

"SyntaxError: Cannot use import statement outside a module",

File must have .mjs extension, not .js

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

Successfully merging this pull request may close these issues.

4 participants