YemSalat YemSalat - 1 year ago 86
Node.js Question

Node http-server not working on Ubuntu linux

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
to my project folder where it has the index.html file, I open the terminal and run

But when I open my browser at
- it can't connect to the host.

Am I missing something?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download