Executing this ngrok command in nodejs is producing no output

Viewed 49

Problem

I am trying to get the shell output after the execution of the following ngrok command. But I am not getting any output. It is starting the tunneling process, but no stdout response.

 const { exec } = require("child_process");
    
 exec("ngrok http 8080", (error, stdout, stderr) => {
        if (error) {
            console.log(`error: ${error.message}`);
            return;
        }
        if (stderr) {
            console.log(`stderr: ${stderr}`);
            return;
        }
        console.log(`stdout: ${stdout}`);
    });

Tried Solutions

Tried using spawn and also the promise version of exec still no luck.

What I am trying to achieve?

Basically, I am trying to get the random URL ngrok creates every time and use it further down the code for some automation-run configurations. Please do suggest if there is any other way to do it.

With any solutions posted please do suggest ways to debug such issues.

0 Answers
Related