Lets write simple program which prints the text in console.Create a new file called "hello.js" in visual studio code and write the following code.
console.log("Hello world...");
How to run nodejs program?
Goto terminal in visual studio code and run the following command.
node hello.js
which prints the "Hello world..." in the terminal. No explanation is needed for this program. console is an built-in module which provided by Nodejs framework ( when you install the nodejs, it gets bundled along with installation) which has several methods i.e
- console.log
- console.info
- console.error
Now you might have question of what is module? Lets dive into this section.