8

I am trying to run a simple http server in my project directory. All I need is GET request support, so I can GET html/css/js/etc. For that I wanted to use http-server from npm.

I installed it with npm install http-server -g

Now I cd to my project folder where it has the index.html file, I open the terminal and run http-server

But when I open my browser at http://localhost:8080/index.html - it can't connect to the host.

Am I missing something?

5
  • From the npm: Starting http-server locally node bin/http-server. Now you can visit localhost:8080 to view your server. npmjs.org/package/http-server ( "Usage" ). Commented Sep 13, 2014 at 12:18
  • Same result - can't connect. Does it store a log anywhere? Commented Sep 13, 2014 at 12:20
  • Doe you have output in the REPL? nodejs.org/api/repl.html Commented Sep 13, 2014 at 12:22
  • Weirdly enough it works on Windows for me but not on linux (Mint 17) Commented Sep 13, 2014 at 12:52
  • 1
    Cool. The REPL is basically a console of V8, docs.nodejitsu.com/articles/REPL/how-to-use-nodejs-repl. Commented Sep 13, 2014 at 16:21

2 Answers 2

27

Okay, the issue was - I had another package installed on Ubuntu, which is also called node

Node JS package is called nodejs on my system and I think that http-server is looking specifically for 'node'. In order to work around this:

I removed the node package with sudo apt-get remove node and created a symlink for nodejs:

sudo ln -s /usr/bin/nodejs /usr/local/bin/node

Sign up to request clarification or add additional context in comments.

Comments

0

First install npm. Second npm install http-server -g.Next append after the http-server url template url like http-server C:\xampp\htdocs\

1 Comment

C drive in Ubuntu?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.