When debugging the node process, I used the --inspect
method and the chrome-devtools://
protocol. I want to automatically open the debug link:
let child_process = require('child_process'),
url = 'http://' + debugUrl;
if (process.platform == 'wind32') {
cmd = 'start "%ProgramFiles%\Internet Explorer\iexplore.exe"';
} else if (process.platform == 'linux') {
cmd = 'xdg-open';
} else if (process.platform == 'darwin') {
cmd = 'open';
}
child_process.exec(`${cmd} "${url}"`);
As a result, the page did not open automatically. I felt that this non-standard protocol was not supported. I had no choice but to use the http://
protocol header, which turned into this link: http: //chrome-devtools//devtools/...
, because the browser automatically omits the http://
part, so manually add it in the middle of chrome-devtools//
colon access.
But manually adding colons feels a bit painful. Is there any way to support this kind of debug protocol header, or use node to control the browser to automatically adjust its url? Using chrome browser (ver 57)
Recommend an npm package, hope it can solve your problem
Open a file or url in the user's preferred application.