简体   繁体   English

为什么我在终端 Nodejs 中没有得到 output?

[英]Why i am not getting output in teminal Nodejs?

function helloworldapp() {
  console.log("Hello World");
} 

I am new to Ndoejs.我是 Ndoejs 的新手。 I have installed node on my windows 10 and in cmd i type node-v it showing me the installed version of nodejs, but when i craeted project on vscode and type node app.js (js file name).我已经在我的 windows 10 上安装了 node,在 cmd 中我输入了 node-v 它显示了 nodejs 的安装版本,但是当我在 vscode 上创建项目并输入 node app.js(js 文件名)时。 it does not showing me any thing in teminal.它没有在终端中向我显示任何内容。 how can i get output of my nodejs program in terminal?我怎样才能在终端中获得我的nodejs程序的output? 在此处输入图像描述

You are only defining the function helloworldapp , not calling it.您只是定义 function helloworldapp ,而不是调用它。

do helloworldapp() to execute the function执行helloworldapp()以执行 function

If this is everything you put in the app.js file, you are not calling your function.如果这就是您放入app.js文件的所有内容,那么您就不会调用您的 function。

function helloworldapp() {
  console.log("Hello world");
}

helloworldapp()

I suggest you follow the nodejs getting started guide.我建议您遵循 nodejs 入门指南。 https://nodejs.org/en/docs/guides/getting-started-guide/ https://nodejs.org/en/docs/guides/getting-started-guide/

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

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