Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If you are on an older version of node and want ESM, but don’t want to use .mjs, you can try:

https://www.npmjs.com/package/esm

The package.json should have something like this if they are going to use import/export statements so anyone on older versions don’t have to worry about it (it’s not native to Node yet without .mjs extension).

We can blame whoever didn’t set that up, or the instructions should have been to just use require().



> it’s not native to Node yet without .mjs extension

Since v13, you can use ES modules without the .mjs extension if the nearest package.json includes `"type": "module"`.


Thank you, that’s good to know.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: