Is it possible to use chrome devtools to execute the terminal mand node myfile.js
, so the chrome console would output all console.log
s from my code?
I have got some terminal plugin installed in my IDE and I use some keyboard shortcuts when I want to run this mand on my files, to get my logs immediately (like when running html+js in the browser) but it prints out just plain text. Chrome can recognize the output data type and structurize it well (arrays, objects), what is really cool.
I've already tried out node inspect-brk
but its purpose seems to be quite different than just printing out my logs.
UPDATE:
I've found very interesting link with npm modules that do what I mean.
I have alredy tested node-monkey
but it does not work on my Windows, but iron-node
works great and I can run my .js
files with iron-node file.js
mand and get all console.log
s in Chrome devtools!
Is it possible to use chrome devtools to execute the terminal mand node myfile.js
, so the chrome console would output all console.log
s from my code?
I have got some terminal plugin installed in my IDE and I use some keyboard shortcuts when I want to run this mand on my files, to get my logs immediately (like when running html+js in the browser) but it prints out just plain text. Chrome can recognize the output data type and structurize it well (arrays, objects), what is really cool.
I've already tried out node inspect-brk
but its purpose seems to be quite different than just printing out my logs.
UPDATE:
I've found very interesting link with npm modules that do what I mean.
I have alredy tested node-monkey
but it does not work on my Windows, but iron-node
works great and I can run my .js
files with iron-node file.js
mand and get all console.log
s in Chrome devtools!
- No, it's not possible, but you can use remote-debugging directly from node.js and use devtools. – woxxom Commented Sep 8, 2017 at 12:23
- web browser and node.js are pletely different host environments in which javascript runtime gets executed in, so, no, it is not possible. Just curious why you would like to do that? – Srle Commented Nov 4, 2017 at 19:28
-
@Srle then try
iron-node
– Paweł Commented Nov 5, 2017 at 5:55
2 Answers
Reset to default 5run your file with
node --inspect <your file name>.js
and then type in chrome
chrome://inspect
See https://nodejs/api/debugger.html#debugger_v8_inspector_integration_for_node_js for reference
--inspect-brk is used for breakpoint purposes, with that flag the debugger is ready to run your code but is expecting the developer to add something before it begins to run your script. There is a play button at the top corner of the chrome devtools debugger, and if there are no other breakpoints or debugger; statments in your code it will run as it would run or your workstation