-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
ESM import error #114
Comments
This module does not have native ESM enabled, so unless you're bundling, you'll be using the CommonJS entry. Even so, this is the correct format. It will always worked and I just verified locally as well: import sirv from 'sirv'; Your TS will be pissed off, but it'll be correct. The format you used should only be used when you have multiple named imports, or if you have a default with named exports. |
Not using TS. Thas was from a |
I just reread the error message, sorry My I'll fix this tomorrow morning and publish a new patch. Just mentioned TS for potential type checking errors. |
Thank you...I think I was having this sort of issue with a few of your packages. I'll be more diligent about error reporting if I come across any issue as I have more time now. And as you said, |
Hey, so I'm sorry to say, you 100% have something else going on. With the currently released // package.json
{
"type": "module",
"devDependencies": {
"sirv": "1.0.12"
}
} // usage.js
import sirv from 'sirv';
import { createServer } from "http";
const assets = sirv('node_modules/sirv');
createServer(assets).listen(3000); $ node usage.js Then a GET to The same thing happens if I remove I'm using Node 14.15.3, but I tested Node 12.18.3 and Node 16.2.0 |
If, however, your This is expected & works as (Node) designed, since But, as seen from my above example, none of this is needed. Node ESM is able to follow the dependency resolutions correctly even though/if they happen to be loading CommonJS code. If Node were not able to do this, native ESM would be dead on arrival since module interop would be impossible. (This was momentarily true, and was quickly fixed) |
The mime issue is resolved via d93f33f sirv@2.0 will support native ESM usage. |
Results with the error:
The text was updated successfully, but these errors were encountered: