我可以在Chrome开发者工具中执行Node

我可以在Chrome开发者工具中执行Node

本文介绍了我可以在Chrome开发者工具中执行Node.js javascript脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

是否可以使用 chrome devtools 执行终端命令node myfile.js,以便chrome控制台将从我的代码中输出所有console.log?我在IDE中安装了一些 terminal 插件,当我想对文件运行此命令时,我会使用一些键盘快捷键,以便立即获取我的日志(例如在html + js中运行时)浏览器),但只打印纯文本. Chrome可以识别输出数据类型并将其结构化为(数组,对象),这真的很酷.

Is it possible to use chrome devtools to execute the terminal command 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 command 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.

我已经尝试过node inspect-brk,但它的目的似乎与仅打印日志有关.

I've already tried out node inspect-brk but its purpose seems to be quite different than just printing out my logs.

更新:

我发现与npm模块非常有趣的链接做到我的意思.

I've found very interesting link with npm modules that do what I mean.

我已经对node-monkey进行了测试,但是在Windows上却无法正常运行,但是iron-node的效果很好,我可以使用iron-node file.js命令运行.js文件,并在Chrome devtools中获取所有的console.log

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.logs in Chrome devtools!

推荐答案

使用

node --inspect <your file name>.js

然后输入chrome

and then type in chrome

chrome://inspect

请参见 https://nodejs.org/api/debugger.html#debugger_v8_inspector_integration_for_node_js供参考

这篇关于我可以在Chrome开发者工具中执行Node.js javascript脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 22:24