Is there an “immediate window” in Visual Studio Code to run Javascript?

霸气de小男生 提交于 2020-02-26 08:01:02

问题


Yes, I use F12 in the browser all the time to test out Javascript snippets with the console. I'm tired of that (for the moment anyway).

I've read that in Visual Studio you can use the immediate window to run Javascript interactively.. I've haven't tried it that hard. I think when I did it told me it can't evaluate while in design mode... ugh, what a pain.

I do like to use Visual Studio Code (sublime text historically) sometimes to just mess around with syntax of snippets. Would also be nice if I could just run Javascript there too quickly. Is there a package I could download in VSCode to do so? Or something already built in?


回答1:


There is no Immediate Window unlike Visual Studio in VSCode. But you can still execute Javascript in VSCode.

Install the Code Runner Extension - https://marketplace.visualstudio.com/items?itemName=formulahendry.code-runner

Open the JavaScript file in VSCode, then use shortcut Ctrl+Alt+N, the code will run and the output will be shown in the Output Window.




回答2:


As of (at least) my current version of VS Code (1.5.2), the "Debug Console", while debugging, lets you run arbitrary JavaScript code as you would in the VS Immediate Window. (Similar to as you would for the Chrome Dev Tools Console.)




回答3:


I've found this extension that makes a scrathpad for JS, that runs at the same time as you are typing: https://quokkajs.com/

Works on VS Code, Jet Brains, and Atom.




回答4:


This might do it: https://code.visualstudio.com/Docs/runtimes/nodejs

Node.js is a platform for building fast and scalable server applications using JavaScript. Node.js is the runtime and NPM is the Package Manager for Node.js modules.

To get started, install Node.js for your platform. The Node Package Manager is included in the Node distribution.



来源:https://stackoverflow.com/questions/32700105/is-there-an-immediate-window-in-visual-studio-code-to-run-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!