starting web server with npm

This is a question from Linux Fundaments on HTB academy.

I’ve been stuck with question for a while now. I’ve search google and entered several answers that I can guess. But none of them worked.

Here is the question.
“Find a way to start a simple HTTP server using “npm”. Submit the command that starts the web server on port 8080 (use the short argument to specify the port number)”

Here is the hint for the question.
“Npm is a package manager that can allow you to download a basic web server packet. This packet also provides the option to specify the port. No need to install it. How would the command look after installing the corresponding package with a specified listening port?”

You can find the npm website about simplehttpserver here → https://www.npmjs.com/package/simplehttpserver .The command to start a webserver is simply “simplehttpserver [directory to be web root,default is the current working directory]”.Also to install simplehttpserver through npm “npm install simplehttpserver -g”.Hope it helps :slight_smile:

@ThorMM said:

This is a question from Linux Fundaments on HTB academy.

I’ve been stuck with question for a while now. I’ve search google and entered several answers that I can guess. But none of them worked.

Here is the question.
“Find a way to start a simple HTTP server using “npm”. Submit the command that starts the web server on port 8080 (use the short argument to specify the port number)”

Here is the hint for the question.
“Npm is a package manager that can allow you to download a basic web server packet. This packet also provides the option to specify the port. No need to install it. How would the command look after installing the corresponding package with a specified listening port?”

This gets asked a few times because IMHO it is a badly worded question. The answer doesn’t need npm.

Spoiler Removed

I have same question,use simplehttpserver 127.0.0.1:8080 & python -m SimpleHTTPServer but can’t work,I don’t know what problemt?

It feels like any attempt to be more specific with an answer here gets flagged as a spoiler. This question gets asked a lot which implies people are struggling with it, but every thread is littered with Spoiler Removed messages.

just a hint forget about any local host or any ip address

Very badly worded question lost a few hours on that because of the word simple. Also not much online this help https://gist.github.com/willurd/5720255

1 Like

Thanks m0j0r1s1n that link helped.
I think the issue with this question is that there has been no mention of this process in the module to this point which makes it pretty hard or someone with no linux knowledge to figure out the answer

Thanks m0j0r1s1n that linked helped as well. I will spread your wisdom!

Thanks m0j0r1s1n, great help!

RE: the way questions are asked
I am only on my first few modules, and I think the wording … really lacks.
The words used to ask questions do not match the words or phrases I have heard used before, and it really makes the academy frustrating.

As everyone seems to complain about this module, proves that I’m not missing something, the module is just bad. I wanted to pay to get access to the other courses but I’ll think again. 1h30 in, still haven’t found the answer btw. Frustrating.

Took me ages to work this out hint : forget about the npm bit , concentrate on what the command would look like assuming npm is already installed
https://www.npmjs.com/package/http-server , look CAREFULLY at usage section

if it helps, this was my journey. And, annoyingly, i don’t fully understand how i solved the question so i’ve missed the point. i was trying to do this on the VM. I’d SSH’ed to ‘htb-student@host’ but I didn’t have the permissions to install npm on that machine. There is a line in the hint stating “No need to install it” so confusingly i was thinking that seeing as i do not have the permissions to install, i use the package without installing it… (!!!) Then, i just used my host VM - no SSH (on the host VM i had the privileges required). I played around and it worked but i don’t know how. I used this resource - i might have found it from someone elses post - i cant remember. I hope it helps… https://www.npmjs.com/package/http-server

Thank you m0j0r1s1n…the link helped… Thanks again

Like has been said, don’t stress over the NPM so much…look at the actual command you’d use and go from there If A Little Knowledge Is A Dangerous thing, Learn, learn, learn and Become Very dangerous

it’s an annoyingly worded question