check out the node 'path' module

path.basepath is pretty handy