I want to use 5000 instead of 4200.
I have tried to create a file on root name ember-cli
and put JSON according to the code below:
{
&q
in angular 2++.
To change port you can run below command in terminal :
ng serve --host 0.0.0.0 --port 5000.
We have two ways to change default port number in Angular.
First way to cli command:
ng serve --port 2400 --open
Second way is by configuration at the location: ProjectName\node_modules\@angular-devkit\build-angular\src\dev-server\schema.json
.
Make changes in schema.json
file.
{
"title": "Dev Server Target",
"description": "Dev Server target options for Build Facade.",
"type": "object",
"properties": {
"browserTarget": {
"type": "string",
"description": "Target to serve."
},
"port": {
"type": "number",
"description": "Port to listen on.",
"default": 2400
},
Go to angular.json
file,
Search for keyword "serve":
Add port
keyword as shown below:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "my-new-angular-app:build",
"port": 3001
},
...
This worked for all users:
ng s -o --port 4450
serve:
s
Builds and serves your app, rebuilding on file changes.
For angular 10+:
Example:
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "dashboard:build",
**"port": 4202**
},
"configurations": {
"production": {
"browserTarget": "dashboard:build:production"
}
}
},
You can change your application port by entering the following command,
ng serve --port 4200
Also, for a permanent setup you can change the port by editing angular-cli.json file
"defaults": {
"serve": {
"port": 8080
}
}