Reputation: 55
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.
Upvotes: 3
Views: 11377
Reputation: 51
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
Upvotes: 5
Reputation: 11
i faced the same issue, but when I checked, it was due to a missing (< >) symbol in my HTML code while connecting it with my JS file , it can be the same reason, please do check
Upvotes: 1
Reputation: 645
Let's do it from scratch Just Follow this Steps-
console.log("hello");
app.js
node app
)Note - make sure you have node install globally You can check by (node -v) and your file app.js is saved
Upvotes: 3