Fix nodejs issue with undefined window variable