MarkusJx / node-java-bridge

A bridge between Node.js and Java
https://markusjx.github.io/node-java-bridge/
MIT License
116 stars 6 forks source link

SyntaxError: Named export 'importClass' not found. #106

Closed AddictArts closed 6 months ago

AddictArts commented 6 months ago

Describe the bug The hello world example does not work out of the box.

To Reproduce Try the hello world example.

Expected behavior No import errors

Environment

Additional context

Needed to use

import pkg from "java-bridge";
const { importClass } = pkg;

Then I also had to use the libPath option for the jvm, but that was not an issue.

MarkusJx commented 6 months ago

Are you using Typescript or an ESM module? The example in the readme is written in Typescript and runs fine if compiled to CommonJS. But I've never tested ESM, so this may be an issue.

AddictArts commented 6 months ago

Hi yes, I am using ESM and not transpiling using vite / webpack / babel / other ...

It makes sense it could work if transpiled, I guess that was implied, but the above works if anyone is using type: "module".

@MarkusJx Thanks