All of the examples can be run in node. Simply copy and paste into a node project with Express installed and run them with node filename. For an example of how to install express click here and ensure you have npm installed then follow the instructions on installing packages to install "express."
// Basic code for Express Instance
var express = require('express');
var app = express();
// Serve static files from directory 'public'
app.use(express.static('public'));
// Start Express server
app.listen(3030);
// Set up Express
var express = require('express');
var app = express();
// Serve static assets from both 'public' and 'files' directory
app.use(express.static('public');
app.use(express.static('files');
// Start Express server
app.listen(3030);
// Set up Express
var express = require('express');
var app = express();
// Specify mount path, '/static', for the static directory
app.use('/static', express.static('public'));
// Start Express server
app.listen(3030);
// Set up Express
var express = require('express');
var app = express();
// Serve files from the absolute path of the directory
app.use(express.static(__dirname + '/public'));
// Start Express server
app.listen(3030);
// Set up Express
var express = require('express');
var app = express();
/* Serve from the absolute path of the directory that you want to serve with a
*/ virtual path prefix
app.use('/static', express.static(__dirname + '/public'));
// Start Express server
app.listen(3030);
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var app = express();
app.use(favicon(__dirname + '/public/img/favicon.ico'));
app.use(express.static(path.join(__dirname, 'public')));
app.listen(3000, function() {
console.log("Express App listening on port 3000");
})