Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why console.log isn't printing anything in VS code terminal and opening the command prompt?

I have installed node js on my system but when i am going to vs code and running app.js it is opening command prompt for a second and then closing it.

So app.js has only one line of code.

console.log('hello World')

i am going to terminal and typing node app.js , it is not printing anything in the console.

This is absolute beginner question but i cant find a fix anywhere why it is happening.

like image 857
Aavesh Avatar asked Sep 11 '25 05:09

Aavesh


1 Answers

There can be multiple issues as described in other answers. One such reason can be an unsaved file.

Do try save the file before try running the same in VS, can save with CTRL + S, then run

like image 70
Rajiv Avatar answered Sep 12 '25 19:09

Rajiv