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

Error: require() of ES Module is not supported #25

Open
pcace opened this issue Nov 17, 2022 · 3 comments
Open

Error: require() of ES Module is not supported #25

pcace opened this issue Nov 17, 2022 · 3 comments

Comments

@pcace
Copy link

pcace commented Nov 17, 2022

Hi,

i am trying to get your library to run in nodejs, but i am stuck importing it correctly. is the problem on my side or is something broken with the library? this is the errormessage:

Error: require() of ES Module C:\Users\user\Documents\citygmlToGltf\node_modules\citygml-to-3dtiles\src\Converter.mjs not supported.
Instead change the require of C:\Users\user\Documents\citygmlToGltf\node_modules\citygml-to-3dtiles\src\Converter.mjs to a dynamic import() which is available in all CommonJS modules.       

when having this in my app.ts:

import Converter from "citygml-to-3dtiles";
  let converter = new Converter();

(i also had to add a citygml-to-3dtiles.d.ts in node-module/@types)
and added "type" : "module", to the package.json of the module... with no luck

any idea what i am doing wrong here?

Thanks a lot!

@njam
Copy link
Owner

njam commented Nov 17, 2022

What's your NodeJS version?
It seems you're using Typescript. Can you try without Typescript, does that work?

The error message suggests using dynamic import, have you tried that? I don't have experience with it, so can't suggest exact syntax.

@pcace
Copy link
Author

pcace commented Nov 17, 2022

hi, my Node.js is v16.14.2.
i will give it a try, but i need to be in TS environment :/

@njam
Copy link
Owner

njam commented Nov 17, 2022

I'm not too knowledgeable about JS modules/import. But it looks to me like the module/file from which you import citygml-to-3dtiles from doesn't support the type of import you're using (the one from this repo's readme). I'd try the dynamic import instead.

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

No branches or pull requests

2 participants