universal-create-react-app icon indicating copy to clipboard operation
universal-create-react-app copied to clipboard

Ambiguous "PORT" environment parameter

Open stasou opened this issue 8 years ago • 0 comments

In 'scripts/start.js', there are these two lines:

const DEFAULT_CLIENT_PORT = parseInt(process.env.PORT, 10) || 3000;
const DEFAULT_SERVER_PORT = parseInt(process.env.PORT, 10) || 5678;

Both constants use the PORT parameter, if provided in as command line argument, for example, in package.json:

//..
  "scripts": {
    "serve": "NODE_ENV=production node ./build/server/bundle.js",
    "start": "PORT=3003 node scripts/start.js",
//...

The above configuration, will, thus, lead to a warning message:

? Something is already running on port 3003. Probably:
  node scripts/start.js
  in /your/own/projects/this_project

Would you like to run the app on another port instead? (Y/n) 

There should be a disambiguation, and there be the possibility to provide PORT number both for client and server, for example:

const DEFAULT_CLIENT_PORT = parseInt(process.env.CPORT, 10) || 3000;
const DEFAULT_SERVER_PORT = parseInt(process.env.SPORT, 10) || 5678;

and

//..
  "scripts": {
    "serve": "NODE_ENV=production node ./build/server/bundle.js",
    "start": "SPORT=5685 CPORT=3003 node scripts/start.js",
//...

stasou avatar Feb 18 '18 00:02 stasou