diff --git a/bin/yarn.js b/bin/yarn.js index 196ebd7571..b34883e948 100755 --- a/bin/yarn.js +++ b/bin/yarn.js @@ -11,18 +11,17 @@ if (majorVer < 4) { console.error('Node version ' + ver + ' is not supported, please use Node.js 4.0 or higher.'); process.exit(1); // eslint-disable-line no-process-exit } else { - var dirPath = '../lib/'; - var v8CompileCachePath = dirPath + 'v8-compile-cache'; - var fs = require('fs'); - // We don't have/need this on legacy builds and dev builds - if (fs.existsSync(v8CompileCachePath)) { - require(v8CompileCachePath); + try { + require(__dirname + '/../lib/v8-compile-cache.js'); + } catch (err) { + // We don't have/need this on legacy builds and dev builds } // Just requiring this package will trigger a yarn run since the // `require.main === module` check inside `cli/index.js` will always // be truthy when built with webpack :( - var cli = require(dirPath + 'cli'); + // `lib/cli` may be `lib/cli/index.js` or `lib/cli.js` depending on the build. + var cli = require(__dirname + '/../lib/cli'); if (!cli.autoRun) { cli.default().catch(function(error) { console.error(error.stack || error.message || error);