Node.js Run Program

How to run Node.js program?

node command is used to run Node.js program.

Below command is used to execute file.

D:\nodejs\website> node server.js  

It runs server.js file.

D:\nodejs\website> nodemon 

This command runs application. If you use nodemon command for your application, then you don't need to run application everytime after changing code.

 

Example (file server.js): 

const express = require('express');

const app = express();

const port =6666;

app.listen(port, () => {

    console.log(`Server running on port: ${port}`);

});

 

//Output : Server running on port: 6666

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

27775