How To

Serving Static Files Locally using Node and Express


A basic setup to serve a folder in a browsable mode using NodeJs and ExpressJS.

const express = require('express');
const app = express();
const serveIndex = require('serve-index');
const port = process.env.PORT || 3000;

app.use(express.static(__dirname + "/"))
app.use('/', serveIndex(__dirname + '/'));

const server = app.listen(port, function() {
    console.log("Server running at port " + port);

Leave a Reply

Your email address will not be published. Required fields are marked *