Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
2ae1772f
Commit
2ae1772f
authored
7 years ago
by
Dan Abramov
Committed by
GitHub
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add temporary support for Node 4.x to global CLI (#2214)
parent
02968ecd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/create-react-app/createReactApp.js
+53
-17
packages/create-react-app/createReactApp.js
packages/create-react-app/index.js
+2
-2
packages/create-react-app/index.js
packages/create-react-app/package.json
+1
-1
packages/create-react-app/package.json
with
56 additions
and
20 deletions
+56
-20
packages/create-react-app/createReactApp.js
+
53
-
17
View file @
2ae1772f
...
@@ -160,7 +160,34 @@ function createApp(name, verbose, version, template) {
...
@@ -160,7 +160,34 @@ function createApp(name, verbose, version, template) {
const
originalDirectory
=
process
.
cwd
();
const
originalDirectory
=
process
.
cwd
();
process
.
chdir
(
root
);
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
()
{
function
shouldUseYarn
()
{
...
@@ -190,7 +217,6 @@ function install(useYarn, dependencies, verbose, isOnline) {
...
@@ -190,7 +217,6 @@ function install(useYarn, dependencies, verbose, isOnline) {
console
.
log
();
console
.
log
();
}
}
}
else
{
}
else
{
checkNpmVersion
();
command
=
'
npm
'
;
command
=
'
npm
'
;
args
=
[
'
install
'
,
'
--save
'
,
'
--save-exact
'
].
concat
(
dependencies
);
args
=
[
'
install
'
,
'
--save
'
,
'
--save-exact
'
].
concat
(
dependencies
);
}
}
...
@@ -212,13 +238,19 @@ function install(useYarn, dependencies, verbose, isOnline) {
...
@@ -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
packageToInstall
=
getInstallPackage
(
version
);
const
allDependencies
=
[
'
react
'
,
'
react-dom
'
,
packageToInstall
];
const
allDependencies
=
[
'
react
'
,
'
react-dom
'
,
packageToInstall
];
console
.
log
(
'
Installing packages. This might take a couple minutes.
'
);
console
.
log
(
'
Installing packages. This might take a couple minutes.
'
);
const
useYarn
=
shouldUseYarn
();
getPackageName
(
packageToInstall
)
getPackageName
(
packageToInstall
)
.
then
(
packageName
=>
checkIfOnline
(
useYarn
).
then
(
isOnline
=>
({
.
then
(
packageName
=>
checkIfOnline
(
useYarn
).
then
(
isOnline
=>
({
isOnline
:
isOnline
,
isOnline
:
isOnline
,
...
@@ -253,6 +285,15 @@ function run(root, appName, version, verbose, originalDirectory, template) {
...
@@ -253,6 +285,15 @@ function run(root, appName, version, verbose, originalDirectory, template) {
);
);
const
init
=
require
(
scriptsPath
);
const
init
=
require
(
scriptsPath
);
init
(
root
,
appName
,
verbose
,
originalDirectory
,
template
);
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
=>
{
.
catch
(
reason
=>
{
console
.
log
();
console
.
log
();
...
@@ -399,22 +440,17 @@ function getPackageName(installPackage) {
...
@@ -399,22 +440,17 @@ function getPackageName(installPackage) {
function
checkNpmVersion
()
{
function
checkNpmVersion
()
{
let
hasMinNpm
=
false
;
let
hasMinNpm
=
false
;
let
npmVersion
=
null
;
try
{
try
{
const
npmVersion
=
execSync
(
'
npm --version
'
).
toString
();
npmVersion
=
execSync
(
'
npm --version
'
).
toString
()
.
trim
()
;
hasMinNpm
=
semver
.
gte
(
npmVersion
,
'
3.0.0
'
);
hasMinNpm
=
semver
.
gte
(
npmVersion
,
'
3.0.0
'
);
}
catch
(
err
)
{
}
catch
(
err
)
{
return
;
// ignore
}
if
(
!
hasMinNpm
)
{
console
.
error
(
chalk
.
red
(
'
Create React App requires npm 3 or higher.
\n
'
+
'
Please update your version of npm.
'
)
);
process
.
exit
(
1
);
}
}
return
{
hasMinNpm
:
hasMinNpm
,
npmVersion
:
npmVersion
,
};
}
}
function
checkNodeVersion
(
packageName
)
{
function
checkNodeVersion
(
packageName
)
{
...
...
This diff is collapsed.
Click to expand it.
packages/create-react-app/index.js
+
2
-
2
View file @
2ae1772f
...
@@ -44,13 +44,13 @@ var currentNodeVersion = process.versions.node;
...
@@ -44,13 +44,13 @@ var currentNodeVersion = process.versions.node;
var
semver
=
currentNodeVersion
.
split
(
'
.
'
);
var
semver
=
currentNodeVersion
.
split
(
'
.
'
);
var
major
=
semver
[
0
];
var
major
=
semver
[
0
];
if
(
major
<
6
)
{
if
(
major
<
4
)
{
console
.
error
(
console
.
error
(
chalk
.
red
(
chalk
.
red
(
'
You are running Node
'
+
'
You are running Node
'
+
currentNodeVersion
+
currentNodeVersion
+
'
.
\n
'
+
'
.
\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.
'
'
Please update your version of Node.
'
)
)
);
);
...
...
This diff is collapsed.
Click to expand it.
packages/create-react-app/package.json
+
1
-
1
View file @
2ae1772f
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
"repository"
:
"facebookincubator/create-react-app"
,
"repository"
:
"facebookincubator/create-react-app"
,
"license"
:
"BSD-3-Clause"
,
"license"
:
"BSD-3-Clause"
,
"engines"
:
{
"engines"
:
{
"node"
:
">=
6
"
"node"
:
">=
4
"
},
},
"bugs"
:
{
"bugs"
:
{
"url"
:
"https://github.com/facebookincubator/create-react-app/issues"
"url"
:
"https://github.com/facebookincubator/create-react-app/issues"
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment