Sometimes I want to run a simple web server in the current directory.

There are many ways to do this. Here's here's one using npm / serve .


npm install serve -g
. ~/.profile


cd /path/to/directory

You get this message:

serving /path/to/directory on port 3000

You can now access the directory in a browser:



There are more options available:

serve -h

Usage: serve [options] [dir]


-h, --help output usage information
-V, --version output the version number
-a, --auth <user>:<pass> specify basic auth credentials
-F, --format <fmt> specify the log format string
-p, --port <port> specify the port [3000]
-H, --hidden enable hidden file serving
-S, --no-stylus disable stylus rendering
-J, --no-jade disable jade rendering
--no-less disable less css rendering
-I, --no-icons disable icons
-L, --no-logs disable request logging
-D, --no-dirs disable directory serving
-f, --favicon <path> serve the given favicon
-C, --cors allows cross origin access serving
--compress gzip or deflate the response
--exec <cmd> execute command on each request