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 trialJuliette Tworsey
Front End Web Development Techdegree Graduate 32,425 Pointshttp-server not working..
Hi
I have installed NPM globally (and locally into a directory for this class) onto my computer via the console (I'm on a MAC OSX 10). I have also managed to install an http-server folder in my node_modules folder. When I attempt to run the http-server in the console with a file path that leads to a folder (in this case it's a test.js file inside of the http-server folder...I also attempted to open a package.json file in the same folder/file path as well) the console returns not one, but two url addresses for me to try. I have tried them both in Firefox and in Safari and I get an error on both even though the console tells me that the server is running.
I'm really lost on this one....lol....
Thanks to anyone who can help:-)
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsHi Karl,
These are the two different file paths that I tried with the http-server that I had installed globally:
/users/juliettetworsey/node_modules/http-server/package.json
/users/juliettetworsey/node_modules/http-server/test/http-server-test
Thanks!
5 Answers
Brigette Eckert
16,957 PointsHave you tried setting a custom port number? ie http-server -p 1337 and http://localhost:1337 ? I usually find this to be more reliable for me than the default port.
Brigette Eckert
16,957 Pointsalso make sure you aren't accidently hitting cntrl + c and shutting down the server- i've done that before.
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsI have not tried that, but I will give it a go. I would have never thought of that!
Thanks!
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsThanks Brigette! -p 3000 works for me:-)
Brigette Eckert
16,957 Pointsglad to hear it :)
Michael Hall
Courses Plus Student 30,909 PointsI'm have trouble with this too. I'm using Chrome. my file structure is like this:
node_app - node_modules app.js index.html
I tried running http-server node_app within the node_app folder and I get:
$ http-server node_app -p 3000 Starting up http-server, serving node_app Available on: http:127.0.0.1:3000 http:192.168.0.5:3000 Hit CTRL-C to stop the server [Tue, 17 Nov 2015 16:54:51 GMT] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36" [Tue, 17 Nov 2015 16:54:51 GMT] "GET /" Error (404): "Not found"
when I run it from one directory upp projects/node_app I get no error, but in the browser it says "This Webpage is not available"
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsAre you using Workspaces or are you going direct from your own terminal on your computer?
On a couple of occasions I have found that following along on my own terminal (along with my own text editor) did the trick.
Michael Hall
Courses Plus Student 30,909 PointsI'm working on my computer. My html file is just a basic setup. It requires the app.js file and has an h1 tag. Would this make a difference?
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsDid you install NPM globally?
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsAlso, you need to have the entire directory selected, not just the index.html file. I hope that helps. I need to review this course again myself:-)
Michael Hall
Courses Plus Student 30,909 PointsI did. Thanks for your help, I'm sure it's something silly, I'm going to move on with the course. I'll get it eventually
Juliette Tworsey
Front End Web Development Techdegree Graduate 32,425 PointsSorry for not being able to help. Good luck. You'll get it next time.
Karl Taylor
4,043 PointsKarl Taylor
4,043 PointsI'm trying to figure out your problem but I'm a little confused! What's your directory structure?
Is this correct? Just a bit confused what you're trying to load on the server!
Also during writing this I think I figured something out. You've installed http-server globally and locally. So it's basically running them both at the same time perhaps?