Your First Node App

First you need to open the command line with basic command knowledge. also need the editor, and I prefer vs code for the development. it has many more features to node developers.


now on the command line we have to create the project folder as we want. following command will show you how to create the project folder by command line and open the vs code with created folder.

mkdir hello
cd hello
code .

now we create the file app.js inside the folder by vs code.

File Explorer app.js

By using the .js file extension, VS Code interprets this file as JavaScript and will evaluate the contents with the JavaScript language service. Refer to the VS Code JavaScript language topic to learn more about JavaScript support.

in our script.js file we create the simple javascript code by following

function sayHello(name) {
console.log('Hi '+ name);
}

sayHello('kushan');

now we are going to execute the code by node. go back to the terminal and hit the following

node script.js

now we can see on the command line it shows the result.

by kushan


avatar
  Subscribe  
Notify of