This is going to be a very quick post on how to serve a folder of static files using Node.js and Express.
First lets start by installing express:
npm install --save express
Now let's set up the dependencies:
var express = require('express'); var app = express();
The last step is to call the .use and .static methods of express:
I would just like to add a couple of notes. "__ dirname" will give you the current directory you app is in so "/client" means that I will be serving the folder client which is inside your current directory.
As a quick recap this is what your code should look like in order to serve the static files on "/" as long as you got express installed.
var express = require('express'); var app = express(); app.use(express.static(__dirname+'/client'));