custom version of require, allowing running in the browser and with node