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 trial

JavaScript Building a MEAN Application Introduction to the MEAN Stack Setting Up an Express Application

Martijn Bakker
Martijn Bakker
16,445 Points

Cannot GET / error

I keep getting the Cannot GET / error. also on the end of the video when i included the public folder with app.use('/', express.static('public'));

I've the same in the video I also copied and paste it into my code without any success.

'use strict';

var express = require('express');

var app = express();

app.use('/', express.static('public'));

app.listen(3000, function() { console.log("The server is running on port 3000!"); });

Mateo Cuervo
Mateo Cuervo
2,511 Points

Hi Martjin did you resolved this? I have the same error, also I think the link provided is mistaken I don't see any public directory

7 Answers

Bill Shannon
Bill Shannon
10,327 Points

The video instruction was unclear about this part.

This worked for me :

app.use('/', express.static('public/public'));
Bill Shannon
Bill Shannon
10,327 Points

the above solution worked if you cloned the mean-todo repo in the notes as suggested.

https://github.com/treehouse-projects/mean-todo

The correct way is to clone the angular-basics repo below...

git clone https://github.com/treehouse/angular-basics .

If you cloned the mean-todo repo first like I did. In order to setup the correct repo, run these commands:

rm -rf public

m -rf .git

mkdir public

cd public

git clone https://github.com/treehouse/angular-basics .
Martijn Bakker
Martijn Bakker
16,445 Points

I fixed it whit added ../ before the public

I am having the same problem but adding ../ didn't seem to help. I've also tried it the way it is written in the video as well and still no luck:

'use strict'

var express = require('express');

var app = express();

app.use('/', express.static('../public'));

app.listen(3000, function() {
  console.log("The server is running.");
});

This actually fixed my issue.

Bill Shannon
Bill Shannon
10,327 Points

lastly, direct express to the proper directory:

app.use('/', express.static('public'));

Hope that helps!

Oscar Alencar
Oscar Alencar
2,798 Points

It worked for me! Tks... but i dont like to do without know whats happening...

I don't know if this will help anyone else or not, but i was having the same problem & couldn't figure it out from watching the video again or based on the comments here. My directories seemed to be set up correctly but i was still getting CANNOT GET when running the app in my browser.

I removed the first parameter - the '/' - in the app.use(); method, then stopped my server & restarted it, refreshed the browser & i'm good to go.

So it ended up looking like app.use(express.static('public'));

Hope that helps someone :)

Nikolas Konrad
Nikolas Konrad
15,045 Points

Worked for me, thanks. Removing the '/' in the app.use(); method AND restarting the server works. Didn't work without restarting the Server!

Mari Rose
Mari Rose
735 Points

if you're cloning your own forked repo, the clone will unpackage the whole app, not just the public folder. You want only the public folder from the forked repo unpackaged in your public folder, which isn't super clear in the video.

Christopher Parke
Christopher Parke
21,978 Points

Well I've spent 11 hours straight on a 9:53 minute video and still can't get any of this to work. That's right I started just after midnight and its 11:15 am now. Literally everything on this video is broken. I'm like 2 inches from pulling the plug on my treehouse subscription and trying out Lynda...This type of careless teaching is exasperating.

Christopher Parke
Christopher Parke
21,978 Points

My brain just feels like swiss cheese and I couldn't even setup the bloody environment in 11 hours. Insane. Just insane.