-
Notifications
You must be signed in to change notification settings - Fork 346
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
Error because import.meta.url
is undefined
#4601
Comments
@nichoth did you ever resolve this? Running ESM with import.meta.url is giving me the same error on AWS Lambda 16x |
@alexcroox |
I don't blame you. The node ecosystem still isn't ready for ESM without a lot of pain during the intial stages of setting up a new project... For any other weary travellers I solved this on AWS by using
|
We do not yet support pure ESM modules in netlify functions. Currently, it will all be compiled to commonjs. Supporting this is on our roadmap though. |
Would love to see support for this, especially with Node 18 and Web API adoption on the backend picking up steam, using |
I believe this should have been resolved a year or two ago! Feel free to reopen if you're still having issues. |
Describe the bug
In order to require older modules, I've been writing this:
This works if I run the file with node my-file.js. However, I’ve been using the package netlify-cli to run things locally, and when I do that, it logs an error saying that
import.meta.url
is undefined:If you want to see in more detail, this is all open source:
https://github.com/nichoth/ssc-server/blob/1965d193da893bb98e98bd9962717d65c32a4f83/netlify/functions/profile/profile.js#L14
This is relevant to this post
Steps to reproduce
Either
Use a lambda function that includes
import.meta.url
, and run it withnetlify-cli
or
clone my example at this commit within git :
https://github.com/nichoth/ssc-server/blob/1965d193da893bb98e98bd9962717d65c32a4f83/netlify/functions/profile/profile.js#L14
Then run
npm start
, which will runnetlify dev
Configuration
Environment
The text was updated successfully, but these errors were encountered: