diff --git a/packages/kbn-optimizer/src/run_optimizer.ts b/packages/kbn-optimizer/src/run_optimizer.ts index ab12cc679bc6..37260e942717 100644 --- a/packages/kbn-optimizer/src/run_optimizer.ts +++ b/packages/kbn-optimizer/src/run_optimizer.ts @@ -39,10 +39,26 @@ export type OptimizerUpdate = Update; export type OptimizerUpdate$ = Rx.Observable; export function runOptimizer(config: OptimizerConfig) { - return Rx.defer(async () => ({ - startTime: Date.now(), - cacheKey: await getOptimizerCacheKey(config), - })).pipe( + return Rx.defer(async () => { + if (process.platform === 'darwin') { + try { + require.resolve('fsevents'); + } catch (error) { + if (error.code === 'MODULE_NOT_FOUND') { + throw new Error( + '`fsevents` module is not installed, most likely because you need to follow the instructions at https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md and re-bootstrap Kibana' + ); + } + + throw error; + } + } + + return { + startTime: Date.now(), + cacheKey: await getOptimizerCacheKey(config), + }; + }).pipe( mergeMap(({ startTime, cacheKey }) => { const bundleCacheEvent$ = getBundleCacheEvent$(config, cacheKey).pipe( observeOn(Rx.asyncScheduler),