diff --git a/lib/local-data.js b/lib/local-data.js
index 5a5178945..44ce66c43 100644
--- a/lib/local-data.js
+++ b/lib/local-data.js
@@ -1,4 +1,5 @@
-var fs = require('fs')
+var fs   = require('fs')
+var Path = require('path')
 
 module.exports = LocalData
 
@@ -35,6 +36,9 @@ LocalData.prototype.get = function() {
 
 LocalData.prototype.sync = function() {
   // Uses sync to prevent ugly race condition
+  try {
+    require('mkdirp').sync(Path.dirname(this.path))
+  } catch(err) {}
   fs.writeFileSync(this.path, JSON.stringify(this.data))
 }