you can use this module for mkdirp it covers some edge cases https://github.com/substack/node-mkdirp