25

I wondering how to launch "Open dedicated DevTools for Node" directly from the (windows or linux) command-line, without using chrome://inspect url then Open dedicated DevTools for Node button ?

My aim is to automatically run debugger for node.js:

launchDedicatedDevToolsForNode();
require('inspector').open(null, null, true); // sync
debugger;

note:
The underlying command, just behind the click handler of "Open dedicated DevTools for Node" link is:

chrome.send("open-node-frontend")
Franck Freiburger
  • 26,310
  • 20
  • 70
  • 95

2 Answers2

0

You have to write your extension on chrome and run the command there

chrome.send("open-node-frontend")

-2

Chrome provides argument --auto-open-devtools-for-tabs to open the developer tools via cli.

Inorder to run dedicated dev tools via node.js process, Use child_process execFile() method. Check out the following snippet.

const execFile = require('child_process').execFileSync;

function launchChrome(path, hostUrl) {
    try {
        let args = [];
        args.push(hostUrl);
        args.push('--auto-open-devtools-for-tabs'); 
        execFile(path, args);
    } catch (error) {
        console.log(error)
    }
}

//launchChrome(`C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`, '127.0.0.1:8000');

Note: Tested and working in Windows

Ashok JayaPrakash
  • 2,115
  • 1
  • 16
  • 22
  • 6
    Your answer is for opening "web" devTools, my aim is to open "dedicated DevTools for Node" to debug the node.js program – Franck Freiburger May 17 '18 at 17:43
  • Just for understanding, VS Code and Webstorm already having debug mode right. What is the differnce between them and "dedicated DevTools for Node" ? – Ashok JayaPrakash May 17 '18 at 17:48
  • 1
    You can open devTools to debug the web page (F12) and you can open devTools to debug running node.js programs (chrome://inspect then click "Open dedicated DevTools for Node" – Franck Freiburger May 17 '18 at 18:44
  • Hey @FranckFreiburger `chrome://inspect then click "Open dedicated DevTools for Node"` -> Did you find a quicker way to do this? – Jose Aug 30 '18 at 01:26