Home > Enterprise >  node index.js command start and end server in the same time
node index.js command start and end server in the same time

Time:10-05

I did install WSL2 and ubuntu 22.04 distribution on windows 11. I configured envoirment, installed nvm, node v.16.17.1, next in my folder did npm init, installed express, created index.js file within simple structure:

const express = require('express')
const app = express()
const port = 3000

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

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

When i tap node index.js nothing happen. image

In my second computer with ubuntu 20.04 distribution everything work fine. Does anyone know what to do?

CodePudding user response:

How about doing debugging by referring to https://expressjs.com/en/guide/debugging.html?

like this,

DEBUG=express:* node index.js

If no other problem is found, it would be good to use the --inspect options. https://nodejs.org/en/docs/guides/debugging-geting-started/

CodePudding user response:

Problem resolve. File need to be SAVE before calling from terminal....

  • Related