最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Can I execute nodejs javascript scripts in chrome devtools? - Stack Overflow

programmeradmin8浏览0评论

Is it possible to use chrome devtools to execute the terminal mand node myfile.js, so the chrome console would output all console.logs 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.logs 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.logs 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.logs in Chrome devtools!

Share Improve this question edited Nov 4, 2017 at 16:33 Paweł asked Sep 8, 2017 at 11:24 PawełPaweł 4,5366 gold badges25 silver badges42 bronze badges 3
  • 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
Add a ment  | 

2 Answers 2

Reset to default 5

run 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

发布评论

评论列表(0)

  1. 暂无评论