"Hello World" Express does not show – I am shown my files instead

Issue

I am trying to build my first app. It’s a calculator that measures the level of caffeine in your blood.
I copied the code from : https://expressjs.com/en/starter/hello-world.html (copied below), but it is not showing a page with the words "Hello World!".
Instead, I see 2 links to my 2 files within my folder "CaffeineCalc" (calculator.js + json file). I have copied below the page it shows me. [what my browser page shows instead of Hello World][1]

const express = require('express');
const app = express();
const port = 5500;

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

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

Let me know if you understand what I am doing wrong. Thanks!
[1]: https://i.stack.imgur.com/L6bnv.png

Solution

From The Picture you provide, it looks like a live-server running and not your NODE application

So To Fix That You Need to open the path of that dir in any terminal or command prompt and run

$ npm install

cause I can’t see any node_module folder

then

$ node index.js

to start the node server

You can now open Your Browser to

http://localhost:5000

Answered By – Ogoh.cyril

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published