fix error check in node@8.x