[英]Can I execute nodejs javascript scripts in chrome devtools?
Is it possible to use chrome devtools to execute the terminal command node myfile.js
, so the chrome console would output all console.log
s from my code? 是否可以使用chrome devtools执行终端命令
node myfile.js
,所以chrome控制台将从我的代码输出所有console.log
? I have got some terminal plugin installed in my IDE and I use some keyboard shortcuts when I want to run this command on my files, to get my logs immediately (like when running html+js in the browser) but it prints out just plain text. 我在IDE中安装了一些终端插件,并且想在文件上运行此命令时使用一些键盘快捷键来立即获取日志(例如在浏览器中运行html + js时),但它只打印纯文本。 Chrome can recognize the output data type and structurize it well (arrays, objects) , what is really cool.
Chrome可以识别输出数据类型并将其结构化(数组,对象) ,这真的很酷。
I've already tried out node inspect-brk
but its purpose seems to be quite different than just printing out my logs. 我已经尝试过
node inspect-brk
但是它的目的似乎与仅打印我的日志完全不同。
UPDATE: 更新:
I've found very interesting link with npm modules that do what I mean. 我发现与npm模块非常有趣的链接可以实现我的意思。
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
command and get all console.log
s in Chrome devtools! 我已经对
node-monkey
进行了测试,但是它不能在Windows上运行,但是iron-node
可以正常工作,我可以使用iron-node file.js
命令运行.js
文件,并在Chrome devtools中获取所有console.log
!
run your file with 使用运行文件
node --inspect <your file name>.js
and then type in chrome 然后输入chrome
chrome://inspect
See https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js for reference 请参阅https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js以获取参考
--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. --inspect-brk用于断点,带有该标志的调试器可以运行您的代码,但是希望开发人员在开始运行脚本之前先添加一些内容。 There is a play button at the top corner of the chrome devtools debugger, and if there are no other breakpoints or debugger;
chrome devtools调试器的左上角有一个播放按钮,如果没有其他断点或调试器,则为播放按钮。 statments in your code it will run as it would run or your workstation
您的代码中的陈述将按其运行方式或您的工作站的方式运行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.