简体   繁体   English

Visual Studio Code 上的 JavaScript - 运行文件需要 Node 吗?

[英]JavaScript on Visual Studio Code - is Node required to run a file?

I am currently trying to catch up with some JS basics, before continuing with my node.js-project.在继续我的 node.js-project 之前,我目前正在尝试了解一些 JS 基础知识。

I wanted to execute the file and kept getting the error 'console is not defined', when I wanted to use console.log('Hello!')当我想使用console.log('Hello!')时,我想执行该文件并不断收到错误“未定义控制台”

The only helpful way to run the file normally was with: node ./myjsfile.js正常运行文件的唯一有用方法是: node ./myjsfile.js

I installed node.js for that node project.我为该节点项目安装了 node.js。

But for just running super basic JavaScript I don't want node.js.但是对于只运行超级基本的 JavaScript,我不想要 node.js。

What are better (lighter!) ways to run my JavaScript files inside Visual Studio Code?在 Visual Studio Code 中运行我的 JavaScript 文件有哪些更好(更轻松!)的方法? Like what's the most basic way to do it?比如最基本的方法是什么?

No, if you do not currently have Node, you will not have the 'play button' to run the code.不,如果您当前没有 Node,您将没有“播放按钮”来运行代码。 So, if you go to Run in the toolbar at the top, you should see some options to run the file.因此,如果您转到顶部工具栏中的“运行” ,您应该会看到一些运行文件的选项。

I'm pretty sure you can just press F1 and then Run Code我很确定你可以按 F1 然后运行代码

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

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