Commit 2ae1772f authored by Dan Abramov's avatar Dan Abramov Committed by GitHub
Browse files

Add temporary support for Node 4.x to global CLI (#2214)

parent 02968ecd
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 56 additions and 20 deletions
+56 -20
......@@ -160,7 +160,34 @@ function createApp(name, verbose, version, template) {
const originalDirectory = process.cwd();
process.chdir(root);
run(root, appName, version, verbose, originalDirectory, template);
if (!semver.satisfies(process.version, '>=6.0.0')) {
console.log(
chalk.yellow(
`You are using Node ${process.version} so the project will be boostrapped with an old unsupported version of tools.\n\n` +
`Please update to Node 6 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 useYarn = shouldUseYarn();
if (!useYarn) {
const npmInfo = checkNpmVersion();
if (!npmInfo.hasMinNpm) {
if (npmInfo.npmVersion) {
console.log(
chalk.yellow(
`You are using npm ${npmInfo.npmVersion} so the project will be boostrapped with an old unsupported version of tools.\n\n` +
`Please update to npm 3 or higher for a better, fully supported experience.\n`
)
);
}
// Fall back to latest supported react-scripts for npm 3
version = 'react-scripts@0.9.x';
}
}
run(root, appName, version, verbose, originalDirectory, template, useYarn);
}
function shouldUseYarn() {
......@@ -190,7 +217,6 @@ function install(useYarn, dependencies, verbose, isOnline) {
console.log();
}
} else {
checkNpmVersion();
command = 'npm';
args = ['install', '--save', '--save-exact'].concat(dependencies);
}
......@@ -212,13 +238,19 @@ function install(useYarn, dependencies, verbose, isOnline) {
});
}
function run(root, appName, version, verbose, originalDirectory, template) {
function run(
root,
appName,
version,
verbose,
originalDirectory,
template,
useYarn
) {
const packageToInstall = getInstallPackage(version);
const allDependencies = ['react', 'react-dom', packageToInstall];
console.log('Installing packages. This might take a couple minutes.');
const useYarn = shouldUseYarn();
getPackageName(packageToInstall)
.then(packageName => checkIfOnline(useYarn).then(isOnline => ({
isOnline: isOnline,
......@@ -253,6 +285,15 @@ function run(root, appName, version, verbose, originalDirectory, template) {
);
const init = require(scriptsPath);
init(root, appName, verbose, originalDirectory, template);
if (version === 'react-scripts@0.9.x') {
console.log(
chalk.yellow(
`\nNote: the project was boostrapped with an old unsupported version of tools.\n` +
`Please update to Node >=6 and npm >=3 to get supported tools in new projects.\n`
)
);
}
})
.catch(reason => {
console.log();
......@@ -399,22 +440,17 @@ function getPackageName(installPackage) {
function checkNpmVersion() {
let hasMinNpm = false;
let npmVersion = null;
try {
const npmVersion = execSync('npm --version').toString();
npmVersion = execSync('npm --version').toString().trim();
hasMinNpm = semver.gte(npmVersion, '3.0.0');
} catch (err) {
return;
}
if (!hasMinNpm) {
console.error(
chalk.red(
'Create React App requires npm 3 or higher. \n' +
'Please update your version of npm.'
)
);
process.exit(1);
// ignore
}
return {
hasMinNpm: hasMinNpm,
npmVersion: npmVersion,
};
}
function checkNodeVersion(packageName) {
......
......@@ -44,13 +44,13 @@ var currentNodeVersion = process.versions.node;
var semver = currentNodeVersion.split('.');
var major = semver[0];
if (major < 6) {
if (major < 4) {
console.error(
chalk.red(
'You are running Node ' +
currentNodeVersion +
'.\n' +
'Create React App requires Node 6 or higher. \n' +
'Create React App requires Node 4 or higher. \n' +
'Please update your version of Node.'
)
);
......
......@@ -8,7 +8,7 @@
"repository": "facebookincubator/create-react-app",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
"node": ">=4"
},
"bugs": {
"url": "https://github.com/facebookincubator/create-react-app/issues"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment