Skip to content

Commit 4b024e9

Browse files
awaseemiansu
authored andcommittedOct 17, 2019
added check for typescript template and unsupported node version (#7839)
* added check for typescript template and unsupported node version * addressed code review feedback regarding syntax and spelling mistakes
1 parent 053f977 commit 4b024e9

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed
 

‎packages/create-react-app/createReactApp.js

+20-11
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,26 @@ function createApp(
193193
useTypescript,
194194
template
195195
) {
196+
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=8.10.0');
197+
if (unsupportedNodeVersion && useTypescript) {
198+
console.log(
199+
chalk.red(
200+
`You are using Node ${process.version} with the TypeScript template. Node 8.10 or higher is required to use TypeScript.\n`
201+
)
202+
);
203+
204+
process.exit(1);
205+
} else if (unsupportedNodeVersion) {
206+
console.log(
207+
chalk.yellow(
208+
`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
209+
`Please update to Node 8.10 or higher for a better, fully supported experience.\n`
210+
)
211+
);
212+
// Fall back to latest supported react-scripts on Node 4
213+
version = 'react-scripts@0.9.x';
214+
}
215+
196216
const root = path.resolve(name);
197217
const appName = path.basename(root);
198218

@@ -222,17 +242,6 @@ function createApp(
222242
process.exit(1);
223243
}
224244

225-
if (!semver.satisfies(process.version, '>=8.10.0')) {
226-
console.log(
227-
chalk.yellow(
228-
`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
229-
`Please update to Node 8.10 or higher for a better, fully supported experience.\n`
230-
)
231-
);
232-
// Fall back to latest supported react-scripts on Node 4
233-
version = 'react-scripts@0.9.x';
234-
}
235-
236245
if (!useYarn) {
237246
const npmInfo = checkNpmVersion();
238247
if (!npmInfo.hasMinNpm) {

0 commit comments

Comments
 (0)