I don’t quite understand the question of permission you mentioned.
The only thing done in his code was to instantiate a server that would run on port 5500 - http://localhost:5500/. However since you do not have any route, when accessing this address should receive Cannot GET /
.
Getting back to your problem, turning the node src/server.js
you were in the root folder ? if you are in the src folder, you should just run node server.js
. This command will not return anything on your terminal, the terminal will get frozen because it will be processing the server on the mentioned port.
For you to have this happening in a more "visual" way, change your file server.js
for that reason:
const express = require('express')
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(5500, () => {
console.log(`O servidor está rodando na porta 5500`)
})
const express = require('express')
and const app = express()
we are declaring that the app variable will be an instance of express.
app.get('/' ...
We are informing that when hitting the root of our server (a /), will be returned only a text written "Hello World". As you advance in the study you will better understand what they are req
, res
, res.send
, etc..
and finally in app.listen(5500, ...
we are informing that we will run the server on port 5500, with a callback that will print in the terminal the information O servidor está rodando na porta 5500
.
Remember to turn around node src/server.js
if it is in the root folder or node server.js
if it’s in the folder src
.