Skip to content
Advertisement

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

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

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement