question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:34 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
newk5commented, May 8, 2021

Thanks I just tried it and I can confirm it works, great job 👍

0reactions
caoccaocommented, May 8, 2021

Wonderful! Thank you for the great help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js HTTP Server Child Process Won't Be Killed in Node.js
I have used exec instead of spawn originally. I tried using SIGTERM and SIGINT , but I have had no luck. The child...
Read more >
How To Create a Web Server in Node.js with the HTTP Module
In this tutorial, you will learn how to build web servers using the http module that's included in Node.js. You will build web...
Read more >
Child process | Node.js v19.3.0 Documentation
The node:child_process module provides the ability to spawn subprocesses in a manner that is similar, but not identical, to popen(3) .
Read more >
Node.js Child Processes: Everything you need to know
The spawn function launches a command in a new process and we can use it to pass that command any arguments. For example,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found