local-cli/server/server.js
function server(argv, config, args) {
  const roots = args.projectRoots.concat(args.root);
  args.projectRoots = roots.concat(
    findSymlinksPaths(NODE_MODULES, roots)
  );

  console.log(formatBanner(
    'Running packager on port ' + args.port + '.\n\n' +
    'Keep this packager running while developing on any JS projects. ' +
    'Feel free to close this tab and run your own packager instance if you ' +
    'prefer.\n\n' +
    'https://github.com/facebook/react-native', {
      marginLeft: 1,
      marginRight: 1,
      paddingBottom: 1,
    })
  );

  console.log(
    'Looking for JS files in\n  ',
    chalk.dim(args.projectRoots.join('\n   ')),
    '\n'
  );

  process.on('uncaughtException', error => {
    if (error.code === 'EADDRINUSE') {
      console.log(
        chalk.bgRed.bold(' ERROR '),
        chalk.red('Packager can\'t listen on port', chalk.bold(args.port))
      );
      console.log('Most likely another process is already using this port');
      console.log('Run the following command to find out which process:');
      console.log('\n  ', chalk.bold('lsof -n -i4TCP:' + args.port), '\n');
      console.log('You can either shut down the other process:');
      console.log('\n  ', chalk.bold('kill -9 <PID>'), '\n');
      console.log('or run packager on different port.');
    } else {
      console.log(chalk.bgRed.bold(' ERROR '), chalk.red(error.message));
      const errorAttributes = JSON.stringify(error);
      if (errorAttributes !== '{}') {
        console.error(chalk.red(errorAttributes));
      }
      console.error(chalk.red(error.stack));
    }
    console.log('\nSee', chalk.underline('http://facebook.github.io/react-native/docs/troubleshooting.html'));
    console.log('for common problems and solutions.');
    process.exit(11);
  });

  runServer(args, config, () => console.log('\nReact packager ready.\n'));
}
function server(argv, config, args) {
  const roots = args.projectRoots.concat(args.root);
  args.projectRoots = roots.concat(
    findSymlinksPaths(NODE_MODULES, roots)
  );

  console.log(formatBanner(
    'Running packager on port ' + args.port + '.\n\n' +
    'Keep this packager running while developing on any JS projects. ' +
    'Feel free to close this tab and run your own packager instance if you ' +
    'prefer.\n\n' +
    'https://github.com/facebook/react-native', {
      marginLeft: 1,
      marginRight: 1,
      paddingBottom: 1,
    })
  );

  console.log(
    'Looking for JS files in\n  ',
    chalk.dim(args.projectRoots.join('\n   ')),
    '\n'
  );

  process.on('uncaughtException', error => {
    if (error.code === 'EADDRINUSE') {
      console.log(
        chalk.bgRed.bold(' ERROR '),
        chalk.red('Packager can\'t listen on port', chalk.bold(args.port))
      );
      console.log('Most likely another process is already using this port');
      console.log('Run the following command to find out which process:');
      console.log('\n  ', chalk.bold('lsof -n -i4TCP:' + args.port), '\n');
      console.log('You can either shut down the other process:');
      console.log('\n  ', chalk.bold('kill -9 <PID>'), '\n');
      console.log('or run packager on different port.');
    } else {
      console.log(chalk.bgRed.bold(' ERROR '), chalk.red(error.message));
      const errorAttributes = JSON.stringify(error);
      if (errorAttributes !== '{}') {
        console.error(chalk.red(errorAttributes));
      }
      console.error(chalk.red(error.stack));
    }
    console.log('\nSee', chalk.underline('http://facebook.github.io/react-native/docs/troubleshooting.html'));
    console.log('for common problems and solutions.');
    process.exit(11);
  });

  runServer(args, config, () => console.log('\nReact packager ready.\n'));
}
function server ( argv , config , args ) { const roots = args . projectRoots . concat ( args . root ) ; args . projectRoots = roots . concat ( findSymlinksPaths ( NODE_MODULES , roots ) ) ; console . log ( formatBanner ( 'Running packager on port ' + args . port + '.\n\n' + 'Keep this packager running while developing on any JS projects. ' + 'Feel free to close this tab and run your own packager instance if you ' + 'prefer.\n\n' + 'https://github.com/facebook/react-native' , { marginLeft : 1 , marginRight : 1 , paddingBottom : 1 , } ) ) ; console . log ( 'Looking for JS files in\n  ' , chalk . dim ( args . projectRoots . join ( '\n   ' ) ) , '\n' ) ; process . on ( 'uncaughtException' , error => { if ( error . code === 'EADDRINUSE' ) { console . log ( chalk . bgRed . bold ( ' ERROR ' ) , chalk . red ( 'Packager can\'t listen on port' , chalk . bold ( args . port ) ) ) ; console . log ( 'Most likely another process is already using this port' ) ; console . log ( 'Run the following command to find out which process:' ) ; console . log ( '\n  ' , chalk . bold ( 'lsof -n -i4TCP:' + args . port ) , '\n' ) ; console . log ( 'You can either shut down the other process:' ) ; console . log ( '\n  ' , chalk . bold ( 'kill -9 <PID>' ) , '\n' ) ; console . log ( 'or run packager on different port.' ) ; } else { console . log ( chalk . bgRed . bold ( ' ERROR ' ) , chalk . red ( error . message ) ) ; const errorAttributes = JSON . stringify ( error ) ; if ( errorAttributes !== '{}' ) { console . error ( chalk . red ( errorAttributes ) ) ; } console . error ( chalk . red ( error . stack ) ) ; } console . log ( '\nSee' , chalk . underline ( 'http://facebook.github.io/react-native/docs/troubleshooting.html' ) ) ; console . log ( 'for common problems and solutions.' ) ; process . exit ( 11 ) ; } ) ; runServer ( args , config , ( ) => console . log ( '\nReact packager ready.\n' ) ) ; }
Starts the React Native Packager Server.
Starts the React Native Packager Server .