Avoid breaking on ENOTDIR errors

This may be due to a node.js bug. If so, could anyone please tell me how to report this bug upstream.

Nevertheless this commit fixes the problem, ash all the existing tests are still passing.