Javet: Can't spawn an http server from node.js inside javet

I have a main.js file with this code:

const express = require("express");
const app = express();

app.listen(3000, "0.0.0.0", () => {
    console.log(`Running server`);
});

And from java I’m doing this:

  V8Host v8Host = V8Host.getNodeInstance();

  V8Runtime v8 = v8Host.createV8Runtime();
  v8.getExecutor(new File("main.js")).execute();
        
  Scanner in = new Scanner(System.in);
  System.out.println("running server, press enter stop");
  in.nextLine();

I dont get any errors but the server never starts either.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 34 (18 by maintainers)

Most upvoted comments

Thanks I just tried it and I can confirm it works, great job šŸ‘