diff --git a/lib/sync-changes.js b/lib/sync-changes.js index c01401fe02..626a1978c1 100644 --- a/lib/sync-changes.js +++ b/lib/sync-changes.js @@ -3,7 +3,7 @@ const EventEmitter = require('events') // npm dependencies const browserSync = require('browser-sync') -const { writeJsonSync } = require('fs-extra') +const { ensureDirSync, writeJsonSync } = require('fs-extra') const path = require('path') const { tmpDir } = require('./utils/paths') const fs = require('fs') @@ -19,7 +19,8 @@ function hasRestartedAfterError () { } function flagError (error) { - writeJsonSync(path.join(tmpDir, 'errors.json'), { error }) + ensureDirSync(path.dirname(errorsFile)) + writeJsonSync(errorsFile, { error }) } function unflagError () {