fix issue when window is undefined. (server side require)