@@ -160,7 +160,34 @@ function createApp(name, verbose, version, template) {
160160 const originalDirectory = process . cwd ( ) ;
161161 process . chdir ( root ) ;
162162
163- run ( root , appName , version , verbose , originalDirectory , template ) ;
163+ if ( ! semver . satisfies ( process . version , '>=6.0.0' ) ) {
164+ console . log (
165+ chalk . yellow (
166+ `You are using Node ${ process . version } so the project will be boostrapped with an old unsupported version of tools.\n\n` +
167+ `Please update to Node 6 or higher for a better, fully supported experience.\n`
168+ )
169+ ) ;
170+ // Fall back to latest supported react-scripts on Node 4
171+ 172+ }
173+
174+ const useYarn = shouldUseYarn ( ) ;
175+ if ( ! useYarn ) {
176+ const npmInfo = checkNpmVersion ( ) ;
177+ if ( ! npmInfo . hasMinNpm ) {
178+ if ( npmInfo . npmVersion ) {
179+ console . log (
180+ chalk . yellow (
181+ `You are using npm ${ npmInfo . npmVersion } so the project will be boostrapped with an old unsupported version of tools.\n\n` +
182+ `Please update to npm 3 or higher for a better, fully supported experience.\n`
183+ )
184+ ) ;
185+ }
186+ // Fall back to latest supported react-scripts for npm 3
187+ 188+ }
189+ }
190+ run ( root , appName , version , verbose , originalDirectory , template , useYarn ) ;
164191}
165192
166193function shouldUseYarn ( ) {
@@ -190,7 +217,6 @@ function install(useYarn, dependencies, verbose, isOnline) {
190217 console . log ( ) ;
191218 }
192219 } else {
193- checkNpmVersion ( ) ;
194220 command = 'npm' ;
195221 args = [ 'install' , '--save' , '--save-exact' ] . concat ( dependencies ) ;
196222 }
@@ -212,13 +238,19 @@ function install(useYarn, dependencies, verbose, isOnline) {
212238 } ) ;
213239}
214240
215- function run ( root , appName , version , verbose , originalDirectory , template ) {
241+ function run (
242+ root ,
243+ appName ,
244+ version ,
245+ verbose ,
246+ originalDirectory ,
247+ template ,
248+ useYarn
249+ ) {
216250 const packageToInstall = getInstallPackage ( version ) ;
217251 const allDependencies = [ 'react' , 'react-dom' , packageToInstall ] ;
218252
219253 console . log ( 'Installing packages. This might take a couple minutes.' ) ;
220-
221- const useYarn = shouldUseYarn ( ) ;
222254 getPackageName ( packageToInstall )
223255 . then ( packageName => checkIfOnline ( useYarn ) . then ( isOnline => ( {
224256 isOnline : isOnline ,
@@ -253,6 +285,15 @@ function run(root, appName, version, verbose, originalDirectory, template) {
253285 ) ;
254286 const init = require ( scriptsPath ) ;
255287 init ( root , appName , verbose , originalDirectory , template ) ;
288+
289+ if ( version === '[email protected] ' ) { 290+ console . log (
291+ chalk . yellow (
292+ `\nNote: the project was boostrapped with an old unsupported version of tools.\n` +
293+ `Please update to Node >=6 and npm >=3 to get supported tools in new projects.\n`
294+ )
295+ ) ;
296+ }
256297 } )
257298 . catch ( reason => {
258299 console . log ( ) ;
@@ -399,22 +440,17 @@ function getPackageName(installPackage) {
399440
400441function checkNpmVersion ( ) {
401442 let hasMinNpm = false ;
443+ let npmVersion = null ;
402444 try {
403- const npmVersion = execSync ( 'npm --version' ) . toString ( ) ;
445+ npmVersion = execSync ( 'npm --version' ) . toString ( ) . trim ( ) ;
404446 hasMinNpm = semver . gte ( npmVersion , '3.0.0' ) ;
405447 } catch ( err ) {
406- return ;
407- }
408-
409- if ( ! hasMinNpm ) {
410- console . error (
411- chalk . red (
412- 'Create React App requires npm 3 or higher. \n' +
413- 'Please update your version of npm.'
414- )
415- ) ;
416- process . exit ( 1 ) ;
448+ // ignore
417449 }
450+ return {
451+ hasMinNpm : hasMinNpm ,
452+ npmVersion : npmVersion ,
453+ } ;
418454}
419455
420456function checkNodeVersion ( packageName ) {
0 commit comments