From c8a6caa842fb09780ca785a439c9fb040d2792b6 Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Tue, 16 Jan 2018 11:43:18 -0700 Subject: [PATCH] Fix #6244, dpendency auto-install fixed Node caches the result of stat on module directories --- src/cli/index.js | 8 ++++++-- src/cli/package-install.js | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli/index.js b/src/cli/index.js index 76ceb5b071..e4679a4e19 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -8,9 +8,9 @@ var dirname = require('./paths').baseDir; // check to make sure dependencies are installed try { - require('../../package.json'); + fs.accessSync(path.join(dirname, 'package.json'), fs.constants.R_OK); } catch (e) { - if (e.code === 'MODULE_NOT_FOUND') { + if (e.code === 'ENOENT') { console.warn('package.json not found.'); console.log('Populating package.json...'); @@ -18,6 +18,8 @@ try { packageInstall.preserveExtraneousPlugins(); try { + fs.accessSync(path.join(dirname, 'node_modules/colors/package.json'), fs.constants.R_OK); + require('colors'); console.log('OK'.green); } catch (e) { @@ -29,6 +31,8 @@ try { } try { + fs.accessSync(path.join(dirname, 'node_modules/semver/package.json'), fs.constants.R_OK); + var semver = require('semver'); var defaultPackage = require('../../install/package.json'); diff --git a/src/cli/package-install.js b/src/cli/package-install.js index 1892a48cfc..4c7a21a429 100644 --- a/src/cli/package-install.js +++ b/src/cli/package-install.js @@ -33,6 +33,8 @@ function installAll() { var prod = global.env !== 'development'; var command = 'npm install'; try { + fs.accessSync(path.join(dirname, 'node_modules/nconf/package.json'), fs.constants.R_OK); + var packageManager = require('nconf').get('package_manager'); if (packageManager === 'yarn') { command = 'yarn';