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 when trying to load libnode from C# code #188

Closed
luanmm opened this issue Dec 25, 2023 · 2 comments
Closed

Error when trying to load libnode from C# code #188

luanmm opened this issue Dec 25, 2023 · 2 comments
Labels

Comments

@luanmm
Copy link

luanmm commented Dec 25, 2023

Hello, dear maintainers/supporters!

I tried to build NodeJS from the fork suggested in #107 (the v20 branch), but even the build working and producing a libnode.so.115 in the <nodejs_root>/out/Release directory, I've got this error when trying to create the environment from C# code:

node:internal/bootstrap/switches/is_embedded_env:18
const internalLoader = new ESMLoader();
                       ^

TypeError: ESMLoader is not a constructor
    at node:internal/bootstrap/switches/is_embedded_env:18:24
    at node:internal/main/embedding:18:34

Node.js v20.0.0

This is the way I'm doing it in C# code:

var libnodePath = "<nodejs_root>/out/Release/libnode.so.115";

var nodejsPlatform = new NodejsPlatform(libnodePath);

var nodejs = nodejsPlatform.CreateEnvironment(); // Here the error was thrown

Am I doing something wrong, perhaps?

For the context: I'm working on Linux (x86_64 architecture).

@jasongin
Copy link
Member

Your code looks fine. Sorry I haven't seen that ESMLoader error and I'm not sure how to fix it. You might try the v19 branch instead of the v20 branch; I'm not sure I tested the v20 branch.

We haven't been focusing as much on the libnode embedding scenarios lately, though I do intend to get back to that soon.

@luanmm
Copy link
Author

luanmm commented Jan 19, 2024

Just to post a feedback: it worked well with v19 (at least the error now is in my "dynamic code" from .NET side), so I think this problem is indeed with v20. I just don't know yet how to do things how I need, like getting results (in .NET) from an external script.js that exports some function calls, for instance.

In my scenario, I would not write .NET code that runs in Node, but would run JS in Node and interop with the .NET system (via JSExports and by calling script exports, like I stated above).

Thanks for the attention, @jasongin. Congratulations for the work here in this project. Hope it can evolve and stabilize soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants