简体   繁体   English

以REPL方式直接从Visual Studio执行javascript(node.js)代码

[英]execute javascript (node.js) code right from Visual Studio in REPL manner

I want to run some javascript code (unit and interaction tests) right in visual studio and be able to see console output. 我想在visual studio中运行一些javascript代码(单元和交互测试),并能够看到控制台输出。 Is it possible to do that with VS??? 用VS ???可以做到吗???

用于Visual Studio的Node.js工具有一个可用于此类事物的node.jsREPL

I love the Interactive Window for Visual Studio (and 2017) but lately I have been starting to use Visual Studio Code. 我喜欢Visual Studio的Interactive Window(和2017),但最近我开始使用Visual Studio Code。 I really like it but the Interactive Window (REPL) is missing. 我真的很喜欢它,但缺少交互式窗口(REPL)。

I need that. 我需要它。 So I tried several extensions but none of them was as good as Node.js Tools for VS. 所以我尝试了几个扩展,但没有一个像Node.js Tools for VS一样好。 The solution was to make one my self, you may need NodeJs 8+ to use Node.js REPL for Visual Studio Code. 解决方案是让我自己,你可能需要NodeJs 8+使用Node.js REPL for Visual Studio Code。

Preview of Node.js REPL for VS Code 用于VS代码的Node.js REPL预览

在此输入图像描述

I believe it is possible, at least to a degree. 我相信这是可能的,至少在某种程度上是可能的。 I haven't done exactly what you're saying, but I do have node running in iis with iisnode. 我还没有完全按照你说的做,但我确实在iis中使用iisnode运行节点。 I also know that there is a version of iisnode that runs under iis express. 我也知道有一个iisnode版本在iis express下运行。 I would look into that. 我会调查一下。

My guess is you would be able to launch a project using the iisnode module, and you could set the default document to the .js file you want to run, but you may only be able to get console output through the browser. 我的猜测是你可以使用iisnode模块启动一个项目,你可以将默认文件设置为你想要运行的.js文件,但是你可能只能通过浏览器获得控制台输出。

iisnode does give you the ability to debug and see the console output through your browser. iisnode确实为您提供了通过浏览器调试和查看控制台输出的功能。 For example, if you run the iisnode module for a file test.js at localhost:1234/test.js , you can get a the browser developer tools by going to localhost:1234/test.js/debug . 例如,如果您在localhost:1234 / test.js上为文件test.js运行iisnode模块,则可以转到localhost:1234 / test.js / debug获取浏览器开发人员工具。 That would give you console output, but I'm not totally certain you would be able to get it directly in VS. 这会给你控制台输出,但我不完全确定你能直接在VS中获得它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM