lesnar
lesnar

Reputation: 2480

Changing Server port on Angular 2

i am trying to change the default "4200" port.

I tried adding the bs-config.json under src like this:

 {
  "port": 9002,
  "files": ["./src/**/*.{html,htm,css,js}"],
  "server": { "baseDir": "./src" }
}

but it did not work. Moreover i searched in my whole project for port 4200 but i did not find the real configuration.

Please help me with this .

Thanks.

UPDATE

i added .ember-cli file in project root with custom port :

{
   "port": 9002
}

and it works.

Upvotes: 2

Views: 6661

Answers (2)

sudheer nunna
sudheer nunna

Reputation: 1719

angular cli provide default port 4200.for change the port number add serve json data into "angular-cli.json" file

 "defaults": {
"styleExt": "css",
"component": {},
"serve": {
  "port": 8080
}

}

Upvotes: 4

JonasMH
JonasMH

Reputation: 1183

Depends on what server software you're using, but based on your port and configuration it's most likely one of these:

Angular2-cli

If you are using something like

ng serve

You are using angular2-cli, and need to provide at port argument like so:

ng serve --port 9002

Source: https://github.com/angular/angular-cli#usage

lite-server

If you're using lite-server, your configuration looks correct, so ensure the configuration is loaded at startup. The console output normally says something like 'couldn't find bs-config.json, using default settings'

Upvotes: 4

Related Questions