Is there any way to set default port for nx react apps

Viewed 2978

I create multiple apps using nx monorepo, but when I try to run nx run-many to start all apps at once, but I got the error that the port is already taken, which is true.

when I run apps one at a time, I can specify a port, but on run-many i can't. so is there any way to set the default port for every app?

Thanks in advance.

1 Answers

you can set the configuration of your react apps by editting project.json file

 "serve": {
  "executor": "@nrwl/web:dev-server",
  "options": {
    "buildTarget": "admin:build",
    "hmr": true,
    "port": 3001
  },
  "configurations": {
    "production": {
      "buildTarget": "admin:build:production",
      "hmr": false
    }
  }
}

under the every command you want to execute, there is an option key which you can add port like me,

Related