-
Notifications
You must be signed in to change notification settings - Fork 551
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
Cannot use import statement outside a module #876
Comments
Bump. I have the same issue on |
I am having this issue with SvelteKit but using TypeScript not JavaScript. Did anyone figure out how to get this imported |
I did this in a TypeScript project and it worked for me: That's obviously sloppy; you shouldn't have to do it. But it works. |
Thanks for the temp fix @JonathanWilbur. I got it to work with that but importing the |
Hello, when importing this in a Javascript (clarifying that it is not Typescript) program, I get the following error:
Even if I go in
nsfwjs
'spackage.json
and add"type": "module"
manually, I get another strange error:My application is a single file that has an extension
.mjs
and I have"type": "module"
in mypackage.json
.My suspicion is that this has been tested with (1) TypeScript that compiles to CommonJS, and (2) Javascript / CommonJS, and the ESM module never worked properly. I am not sure what it would take, though; the
package.json
looks correct to me.For reference, I am also importing several other ESM modules in my
main.mjs
prior to this one, so this isn't a problem with loading ESM modules in general.I am using
Node.js v20.16.0
.Thanks in advance for your help. I'd be happy to offer more information or even contribute code to fix this.
The text was updated successfully, but these errors were encountered: