From 6e0c69535b59ef334e711454a5130d3588b10f43 Mon Sep 17 00:00:00 2001 From: Mikael Carpenter Date: Fri, 17 May 2019 16:07:37 -0700 Subject: [PATCH] ISS-6802 Check devDep for react-scripts and make sure it exists before using semver --- lib/cli/generators/REACT_SCRIPTS/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/cli/generators/REACT_SCRIPTS/index.js b/lib/cli/generators/REACT_SCRIPTS/index.js index d5716cb54880..82e5906b5f47 100644 --- a/lib/cli/generators/REACT_SCRIPTS/index.js +++ b/lib/cli/generators/REACT_SCRIPTS/index.js @@ -39,7 +39,10 @@ export default async npmOptions => { // When working with `create-react-app@>=2.0.0`, we know `babel-loader` is installed. let babelDependencies = []; - if (semver.gtr('2.0.0', packageJson.dependencies['react-scripts'])) { + const reactScriptsDep = + packageJson.dependencies['react-scripts'] || packageJson.devDependencies['react-scripts']; + + if (reactScriptsDep && semver.gtr('2.0.0', reactScriptsDep)) { babelDependencies = await getBabelDependencies(npmOptions, packageJson); }