Yes, there is a simple npm package called http-server
that you can use to run a basic HTTP server. You can install it globally or use npx
to run it without installing it globally. Here's how you can use it with npx
:
bashnpx http-server
This command will start a simple HTTP server in the current directory, serving files from that directory on http://localhost:8080
by default.
If you want to serve files from a specific directory, you can specify the directory as an argument:
bashnpx http-server path/to/directory
This will start the server in the specified directory.
You can also specify the port number using the -p
or --port
option:
bashnpx http-server -p 3000
This will start the server on port 3000 instead of the default port 8080.