| 788 | } |
| 789 | |
| 790 | function checkNodeVersion(packageName) { |
| 791 | const packageJsonPath = path.resolve( |
| 792 | process.cwd(), |
| 793 | 'node_modules', |
| 794 | packageName, |
| 795 | 'package.json' |
| 796 | ); |
| 797 | |
| 798 | if (!fs.existsSync(packageJsonPath)) { |
| 799 | return; |
| 800 | } |
| 801 | |
| 802 | const packageJson = require(packageJsonPath); |
| 803 | if (!packageJson.engines || !packageJson.engines.node) { |
| 804 | return; |
| 805 | } |
| 806 | |
| 807 | if (!semver.satisfies(process.version, packageJson.engines.node)) { |
| 808 | console.error( |
| 809 | chalk.red( |
| 810 | 'You are running Node %s.\n' + |
| 811 | 'Create React App requires Node %s or higher. \n' + |
| 812 | 'Please update your version of Node.' |
| 813 | ), |
| 814 | process.version, |
| 815 | packageJson.engines.node |
| 816 | ); |
| 817 | process.exit(1); |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | function checkAppName(appName) { |
| 822 | const validationResult = validateProjectName(appName); |