Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrenda Cecato
7,704 PointsCannot GET/ error when trying to execute Express
I'm following the Basic Express tutorial, but at the very beginning, I got stuck. My code is the following one and every time I try to access it through the localhost is says the same "Cannot GET /".
I have tried using node.js and my code is running properly yet I cannot make it work with Express.
I have installed the app through npm install and also the plugin for vscode since it is the text editor I'm using. Also I know on the video the port is 3000 but for some reason Express on vscode only allows me to open it on port 80.
const express = require ('express');
const app = express();
app.set('view engine', 'pug' );
app.get('/', (req, res) =>{
res.render('index');
});
app.get('/hello', (req, res) =>{
res.send('<h1>Hello Javascript developer!</h1>');
});
app.listen(80, () =>{
console.log('The application is running on localhost:80');
}); //80 goes to the name of the server