mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-13 09:00:30 +08:00
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
This commit is contained in:
committed by
Ian Sutherland
parent
053f9774d3
commit
4b024e976d
@@ -193,6 +193,26 @@ function createApp(
|
||||
useTypescript,
|
||||
template
|
||||
) {
|
||||
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=8.10.0');
|
||||
if (unsupportedNodeVersion && useTypescript) {
|
||||
console.log(
|
||||
chalk.red(
|
||||
`You are using Node ${process.version} with the TypeScript template. Node 8.10 or higher is required to use TypeScript.\n`
|
||||
)
|
||||
);
|
||||
|
||||
process.exit(1);
|
||||
} else if (unsupportedNodeVersion) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
|
||||
`Please update to Node 8.10 or higher for a better, fully supported experience.\n`
|
||||
)
|
||||
);
|
||||
// Fall back to latest supported react-scripts on Node 4
|
||||
version = 'react-scripts@0.9.x';
|
||||
}
|
||||
|
||||
const root = path.resolve(name);
|
||||
const appName = path.basename(root);
|
||||
|
||||
@@ -222,17 +242,6 @@ function createApp(
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (!semver.satisfies(process.version, '>=8.10.0')) {
|
||||
console.log(
|
||||
chalk.yellow(
|
||||
`You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
|
||||
`Please update to Node 8.10 or higher for a better, fully supported experience.\n`
|
||||
)
|
||||
);
|
||||
// Fall back to latest supported react-scripts on Node 4
|
||||
version = 'react-scripts@0.9.x';
|
||||
}
|
||||
|
||||
if (!useYarn) {
|
||||
const npmInfo = checkNpmVersion();
|
||||
if (!npmInfo.hasMinNpm) {
|
||||
|
||||
Reference in New Issue
Block a user