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 trialStacey Graham
7,039 PointsWhy does the directory index appear when I try to run my code?
The directory index appears when I try to run my code in the browser. Why is this happening?
4 Answers
Steven Parker
231,248 PointsShowing the directory listing is the default behavior when the landing page is not present.
So most likely, your landing page has been named something other than "index.html", or it is located in a sub-folder instead of the root folder.
If you still have trouble, make a snapshot of your workspace and post the link to it here so we can get a better look at the situation.
Update: So you have an "index.html" file, but it's currently located in the "css" sub-folder. Move it to the root folder so it will become the default landing page when you start the preview.
Also, the page is expecting to find the "math.js" file in the "js" sub-folder, but it is currently in the root folder. Move it into the "js" folder so the page can find it.
You can move the files by dragging them in the files pane, or you can enter these commands in the Console pane:
mv css/index.html .
note the period there after the space
mv math.js js
Stacey Graham
7,039 PointsHere is a snapshot of my workspace https://w.trhou.se/ok6g9hn1zf
Stacey Graham
7,039 PointsI'm still having trouble dragging these files to the right folders. What do you have to enter in the console in addition to the mv commands? here is my workspace https://w.trhou.se/iizq3w4uhz
Stacey Graham
7,039 PointsI finally got it to run correctly! Thanks Steven for your help!
Stacey Graham
7,039 PointsStacey Graham
7,039 PointsWhere is the command pane? I can't drag the some of the files.
Steven Parker
231,248 PointsSteven Parker
231,248 PointsI meant Console pane (I fixed it above), it's usually down at the bottom. But dragging the files in my fork(copy) also seemed to work.
Also, when the files are in the right places you'll only see a blank page because there are some syntax errors in the JS:
Steven Parker
231,248 PointsSteven Parker
231,248 PointsIt looks like the dragging did re-arrange things, but not quite in the right places. Here's how they look now:
And here's how they should be arranged:
You could drag them to the right places, or use these commands (not both):
And there's some new issues in "math.js":