Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript npm Basics (retiring) Installing Packages with npm Installing Global Packages

http-server not working for me either

I started with... $ npm install http-server -g

first attempt to get it to work... $ http-server my_project

second attempt ... $ http-server C:\Users\leemsy\Desktop\my_project

third attempt ... $ http-server "C:\Users\leemsy\Desktop\my_project"

fourth attempt ... $ http-server C:\Users\leemsy\Desktop\my_project\index.html

Nothing works.

2 Answers

Found the problem: https://stackoverflow.com/questions/56364464/http-server-with-localhost3000-gives-err-invalid-redirect

"Try downgrading the http-server version as the latest version (0.10.0 and 0.11.0) is causing issue due to ecstatic (3.3.2). Try uninstalling the current http-server version and then try to install 0.9.0 or older version." $ npm uninstall -g http-server $ npm install http-server@0.9.0

Also, make sure you install the server in the directory the website will be run out of. ;)

Here is what I did.

1.) I created a new directory (in my Desktop directory) called "my_project" that contains an index.html file.

2.) I located to the "my_project" directory in windows powershell and typed

npm install http-server@0.9.0

3.) I typed in node and the entire path to the http-server file.

node C:\Users\leemsy\Desktop\my_project\node_modules\http-server\bin\http-server

4.) Then I saw this ... http://156.166.1.36:8080 http://101.156.1.56:8081

Type http://156.166.1.36:8080/index.html into your browser and the page should come up. Be sure to refresh the page.