Added check for undefined stat object
main.js from npm version