DEV Community

FrugalisMinds
FrugalisMinds

Posted on

How to exit from in node JS program Programmatically

 One of the way is by using Control + c ,  but what we are  you are getting here is we want to close our program programmatically. In order to achieve this we are going to use the process module present in NodeJS
. Lets see How and Is it a good way of doing it ?

const express = require('express')

const app = express()

app.get('/', (req, res) => {
  res.send('Hi Nodejstuts!')
})

const server = app.listen(3000, () => console.log('Server Listening In Nodejstuts'))
Enter fullscreen mode Exit fullscreen mode

Have a look at few other scenarios here .

Top comments (0)