simple nodejs server

Been playing with d3js, now that most of the browsers won’t let me load files from disk. To get around this I am using node as my local server. But it is very bare bones.

To make node behave as file server I installed two node-modules: connect and serve-static Once that is installed code for static server is (server.js):

let connect = require('connect');
let serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8080, function(){
    console.log('Server running on 8080...');

To get the server up and running, execute node server.js and connect thru browser.

Or the alternate is to install http-server node module

npm install http-server -g
http-server <directory-to-serve>