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 trialMartijn Bakker
16,445 PointsCannot 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!"); });
7 Answers
Bill Shannon
10,327 PointsThe video instruction was unclear about this part.
This worked for me :
app.use('/', express.static('public/public'));
Bill Shannon
10,327 Pointsthe 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
16,445 PointsI fixed it whit added ../ before the public
David Drysdale
10,815 PointsI 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.");
});
Veronica Rivera
32,599 PointsThis actually fixed my issue.
Bill Shannon
10,327 Pointslastly, direct express to the proper directory:
app.use('/', express.static('public'));
Hope that helps!
Oscar Alencar
2,798 PointsIt worked for me! Tks... but i dont like to do without know whats happening...
John Medcraft
7,976 PointsI 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
15,045 PointsWorked for me, thanks. Removing the '/' in the app.use(); method AND restarting the server works. Didn't work without restarting the Server!
Mari Rose
735 Pointsif 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.
Martijn Bakker
16,445 PointsDid you do npm install?
Christopher Parke
21,978 PointsWell 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
21,978 PointsMy brain just feels like swiss cheese and I couldn't even setup the bloody environment in 11 hours. Insane. Just insane.
Mateo Cuervo
2,511 PointsMateo Cuervo
2,511 PointsHi 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