Home > Back-end >  'PORT' is not recognized as an internal or external command React
'PORT' is not recognized as an internal or external command React

Time:01-17

Someone shared with me the code of an application, now I am trying to study it, understand the code before moving on to the next stage of improving it. Funny that the developer is missing in action and he didn't document anything.

Now, launching the app only has been a problem and I notice the error is coming from package.json file. This is the section with the code error:

  "scripts": {
    "start": "PORT=3333 bash -c 'node scripts/start.js'",
    "build": "node scripts/build.js",
    "test": "node scripts/test.js --env=jsdom"
  },

Now I am running this app on VS CODE on windows 10. I understand on windows you don't have to declare the port at all on that start line but I am wondering how can I rewrite the start line so that to have it working. Any ideas will be highly appreciated.

CodePudding user response:

The Linux shell command

PORT=3333 bash -c 'node scripts/start.js'

starts a new bash process with the environment variable PORT set to 3333, cf. e.g. How do I set an environment variable on the command line.

For cross-pltform compatibility, you can use the cross-env library. (Note however that it's only in maintainance mode.) You can probably use this:

cross-env PORT=3333 node scripts/start.js
  • Related