Does anyone know how to get pass this lesson?, i have created myApp.js file in glitch, put inside this code.:
var express = require (“express”);
var app = express();
app.get("/", function(req, res) {
res.send(‘Hello Express’);
});
//on port 3000 it was throwing error, on 3001 the error is gone but i cannot get anything and it doesnt work on localhost:3001/
app.listen(3001, function() {
console.log(‘Listening on port 3000’);
});
Got stuck…
I was able to get it to run with basically your code:
var express = require ("express");
var app = express();
app.get("/", function(req, res) {
res.send('Hello Express');
});
app.listen(3000, function() {
console.log('Listening on port 3000');
});
And that was on port 3000. I would reboot and try again.
Actually you don’t need to write the app.listen part, for the reason mentioned at line 54, myApp.js
here is where I got the js script:
https://expressjs.com/en/guide/routing.html
“Hello Express” should appear on the web page.
donjon
5
well this post is very old but on testing alot odd apostrophes throwed an error
plus require(‘express’)
not require (space) (‘express’)
my code
it show Hello Express as required by the X isn’t being marked after saying test completed.
i dont know what is wrong
hmdroh
7
Actually you don’t need to write this line:
app.listen(........);
It has already been used in “server.js” file