@@ -14,6 +14,7 @@ const path = require('path');
14
14
const url = require ( 'url' ) ;
15
15
const chalk = require ( 'chalk' ) ;
16
16
const detect = require ( 'detect-port-alt' ) ;
17
+ const isRoot = require ( 'is-root' ) ;
17
18
const inquirer = require ( 'inquirer' ) ;
18
19
const clearConsole = require ( './clearConsole' ) ;
19
20
const formatWebpackMessages = require ( './formatWebpackMessages' ) ;
@@ -378,14 +379,19 @@ function choosePort(host, defaultPort) {
378
379
if ( port === defaultPort ) {
379
380
return resolve ( port ) ;
380
381
}
382
+ const message = process . platform !== 'win32' &&
383
+ defaultPort < 1024 &&
384
+ ! isRoot ( )
385
+ ? `Admin permissions are required to run a server on a port below 1024.`
386
+ : `Something is already running on port ${ defaultPort } .` ;
381
387
if ( isInteractive ) {
382
388
clearConsole ( ) ;
383
389
const existingProcess = getProcessForPort ( defaultPort ) ;
384
390
const question = {
385
391
type : 'confirm' ,
386
392
name : 'shouldChangePort' ,
387
393
message : chalk . yellow (
388
- `Something is already running on port ${ defaultPort } .` +
394
+ message +
389
395
`${ existingProcess ? ` Probably:\n ${ existingProcess } ` : '' } `
390
396
) + '\n\nWould you like to run the app on another port instead?' ,
391
397
default : true ,
@@ -398,9 +404,7 @@ function choosePort(host, defaultPort) {
398
404
}
399
405
} ) ;
400
406
} else {
401
- console . log (
402
- chalk . red ( `Something is already running on port ${ defaultPort } .` )
403
- ) ;
407
+ console . log ( chalk . red ( message ) ) ;
404
408
resolve ( null ) ;
405
409
}
406
410
} ) ,
0 commit comments