Set default host and port for ng serve in config file
I want to know if i can set a host and a port in a config file so I don't have to type
ng serve --host foo.bar --port 80
instead of just
ng serve
angular angular-cli
add a comment |
I want to know if i can set a host and a port in a config file so I don't have to type
ng serve --host foo.bar --port 80
instead of just
ng serve
angular angular-cli
add a comment |
I want to know if i can set a host and a port in a config file so I don't have to type
ng serve --host foo.bar --port 80
instead of just
ng serve
angular angular-cli
I want to know if i can set a host and a port in a config file so I don't have to type
ng serve --host foo.bar --port 80
instead of just
ng serve
angular angular-cli
angular angular-cli
edited Jun 13 '16 at 13:06
Marek Grác
199117
199117
asked Jun 11 '16 at 9:29
cre8cre8
6,90132141
6,90132141
add a comment |
add a comment |
10 Answers
10
active
oldest
votes
Angular CLI 6+
In the latest version of Angular, this is set in the angular.json
config file. Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4444
}
}
}
}
}
}
You can also use ng config
to view/edit values:
ng config projects["my-project"].architect["serve"].options {port:4444}
Angular CLI <6
In previous versions, this was set in angular-cli.json
underneath the defaults
element:
{
"defaults": {
"serve": {
"port": 4444,
"host": "10.1.2.3"
}
}
}
6
To make things easier, you can specify0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.
– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
add a comment |
As of right now that feature is not supported, however if this is something that bothers you an alternative would be in your package.json...
"scripts": {
"start": "ng serve --host foo.bar --port 80"
}
This way you can simply run npm start
Another option if you want to do this across multiple projects is to create an alias, which you can potentially name ngserve
which will execute your above command.
add a comment |
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
https://github.com/angular/angular-cli
add a comment |
This changed in the latest Angular CLI.
The file name changed to angular.json
, and the structure also changed.
This is what you should do:
"projects": {
"project-name": {
...
"architect": {
"serve": {
"options": {
"host": "foo.bar",
"port": 80
}
}
}
...
}
}
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
add a comment |
Another option is to run ng serve
command with the --port
option e.g
ng serve --port 5050
(i.e for port 5050)
Alternatively, the command: ng serve --port 0
, will auto assign an available port for use.
The--port 0
bit was nice info but I'm not sure it answers the question.
– Ash
Nov 27 '18 at 3:38
add a comment |
You can save these in a file, but you have to to put it in .ember-cli
(at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924
{
"port": 4201,
"liveReload": true,
"host": "dev.domain.org",
"live-reload-port": 49153
}
edit: you can now set these in angular-cli.json as of commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9, which is in build 1.0.0-beta.30
add a comment |
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: ProjectNamenode_modules@angular-devkitbuild-angularsrcdev-serverschema.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
},
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
add a comment |
If your are on windows you can do it this way :
- In your project root directory, Create file run.bat
- Add your command with your choice of configurations in this file. For Example
ng serve --host 192.168.1.2 --open
- Now you can click and open this file whenever you want to serve.
This not standard way but comfortable to use (which I feel).
add a comment |
here is what i put into package.json (running angular 6):
{
"name": "local-weather-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 5000",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Then a plain npm start will pull in the contents of start. Could also add other options to contents
add a comment |
enter image description here
Only one thing you have to do. Type this in in your Command Prompt:
ng serve --port 4021 [or any other port you want to assign eg: 5050, 5051 etc ]. No need to do changes in files.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37762125%2fset-default-host-and-port-for-ng-serve-in-config-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
10 Answers
10
active
oldest
votes
10 Answers
10
active
oldest
votes
active
oldest
votes
active
oldest
votes
Angular CLI 6+
In the latest version of Angular, this is set in the angular.json
config file. Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4444
}
}
}
}
}
}
You can also use ng config
to view/edit values:
ng config projects["my-project"].architect["serve"].options {port:4444}
Angular CLI <6
In previous versions, this was set in angular-cli.json
underneath the defaults
element:
{
"defaults": {
"serve": {
"port": 4444,
"host": "10.1.2.3"
}
}
}
6
To make things easier, you can specify0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.
– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
add a comment |
Angular CLI 6+
In the latest version of Angular, this is set in the angular.json
config file. Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4444
}
}
}
}
}
}
You can also use ng config
to view/edit values:
ng config projects["my-project"].architect["serve"].options {port:4444}
Angular CLI <6
In previous versions, this was set in angular-cli.json
underneath the defaults
element:
{
"defaults": {
"serve": {
"port": 4444,
"host": "10.1.2.3"
}
}
}
6
To make things easier, you can specify0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.
– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
add a comment |
Angular CLI 6+
In the latest version of Angular, this is set in the angular.json
config file. Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4444
}
}
}
}
}
}
You can also use ng config
to view/edit values:
ng config projects["my-project"].architect["serve"].options {port:4444}
Angular CLI <6
In previous versions, this was set in angular-cli.json
underneath the defaults
element:
{
"defaults": {
"serve": {
"port": 4444,
"host": "10.1.2.3"
}
}
}
Angular CLI 6+
In the latest version of Angular, this is set in the angular.json
config file. Example:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"projects": {
"my-project": {
"architect": {
"serve": {
"options": {
"port": 4444
}
}
}
}
}
}
You can also use ng config
to view/edit values:
ng config projects["my-project"].architect["serve"].options {port:4444}
Angular CLI <6
In previous versions, this was set in angular-cli.json
underneath the defaults
element:
{
"defaults": {
"serve": {
"port": 4444,
"host": "10.1.2.3"
}
}
}
edited Feb 13 at 13:59
answered Mar 14 '17 at 14:24
Toby JToby J
7,45153942
7,45153942
6
To make things easier, you can specify0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.
– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
add a comment |
6
To make things easier, you can specify0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.
– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
6
6
To make things easier, you can specify
0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.– dman
Jan 2 '18 at 21:14
To make things easier, you can specify
0.0.0.0
instead of the host ip to listen on all Ethernet devices. This way both local host and public ip address can be used.– dman
Jan 2 '18 at 21:14
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
VS2017 seems to ignore the port setting for some weird reason, but I used this trick with @dman 's addition (0.0.0.0 as host) to at least enable remote connections.
– Ola Berntsson
Mar 23 '18 at 19:53
4
4
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
It seems that things have changed in recent versions of the CLI (I'm using version 6). See here for more details.
– Nathan Friend
May 14 '18 at 14:43
add a comment |
As of right now that feature is not supported, however if this is something that bothers you an alternative would be in your package.json...
"scripts": {
"start": "ng serve --host foo.bar --port 80"
}
This way you can simply run npm start
Another option if you want to do this across multiple projects is to create an alias, which you can potentially name ngserve
which will execute your above command.
add a comment |
As of right now that feature is not supported, however if this is something that bothers you an alternative would be in your package.json...
"scripts": {
"start": "ng serve --host foo.bar --port 80"
}
This way you can simply run npm start
Another option if you want to do this across multiple projects is to create an alias, which you can potentially name ngserve
which will execute your above command.
add a comment |
As of right now that feature is not supported, however if this is something that bothers you an alternative would be in your package.json...
"scripts": {
"start": "ng serve --host foo.bar --port 80"
}
This way you can simply run npm start
Another option if you want to do this across multiple projects is to create an alias, which you can potentially name ngserve
which will execute your above command.
As of right now that feature is not supported, however if this is something that bothers you an alternative would be in your package.json...
"scripts": {
"start": "ng serve --host foo.bar --port 80"
}
This way you can simply run npm start
Another option if you want to do this across multiple projects is to create an alias, which you can potentially name ngserve
which will execute your above command.
answered Jun 13 '16 at 13:08
BroccoBrocco
40.2k85271
40.2k85271
add a comment |
add a comment |
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
https://github.com/angular/angular-cli
add a comment |
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
https://github.com/angular/angular-cli
add a comment |
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
https://github.com/angular/angular-cli
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
https://github.com/angular/angular-cli
answered Nov 3 '16 at 7:24
Shreekant NShreekant N
6951823
6951823
add a comment |
add a comment |
This changed in the latest Angular CLI.
The file name changed to angular.json
, and the structure also changed.
This is what you should do:
"projects": {
"project-name": {
...
"architect": {
"serve": {
"options": {
"host": "foo.bar",
"port": 80
}
}
}
...
}
}
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
add a comment |
This changed in the latest Angular CLI.
The file name changed to angular.json
, and the structure also changed.
This is what you should do:
"projects": {
"project-name": {
...
"architect": {
"serve": {
"options": {
"host": "foo.bar",
"port": 80
}
}
}
...
}
}
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
add a comment |
This changed in the latest Angular CLI.
The file name changed to angular.json
, and the structure also changed.
This is what you should do:
"projects": {
"project-name": {
...
"architect": {
"serve": {
"options": {
"host": "foo.bar",
"port": 80
}
}
}
...
}
}
This changed in the latest Angular CLI.
The file name changed to angular.json
, and the structure also changed.
This is what you should do:
"projects": {
"project-name": {
...
"architect": {
"serve": {
"options": {
"host": "foo.bar",
"port": 80
}
}
}
...
}
}
answered Jul 4 '18 at 13:46
arsanyfarsanyf
5531610
5531610
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
add a comment |
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
1
1
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
Worked for me with @angular/cli version 6.1.5
– PHEDev
Sep 13 '18 at 19:56
1
1
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
Worked for me with @angular/cli version 7.0.6
– Kerry Jones
Nov 20 '18 at 0:45
add a comment |
Another option is to run ng serve
command with the --port
option e.g
ng serve --port 5050
(i.e for port 5050)
Alternatively, the command: ng serve --port 0
, will auto assign an available port for use.
The--port 0
bit was nice info but I'm not sure it answers the question.
– Ash
Nov 27 '18 at 3:38
add a comment |
Another option is to run ng serve
command with the --port
option e.g
ng serve --port 5050
(i.e for port 5050)
Alternatively, the command: ng serve --port 0
, will auto assign an available port for use.
The--port 0
bit was nice info but I'm not sure it answers the question.
– Ash
Nov 27 '18 at 3:38
add a comment |
Another option is to run ng serve
command with the --port
option e.g
ng serve --port 5050
(i.e for port 5050)
Alternatively, the command: ng serve --port 0
, will auto assign an available port for use.
Another option is to run ng serve
command with the --port
option e.g
ng serve --port 5050
(i.e for port 5050)
Alternatively, the command: ng serve --port 0
, will auto assign an available port for use.
edited Oct 3 '18 at 10:39
mvermand
2,56722447
2,56722447
answered Jan 26 '18 at 7:59
MwizakMwizak
1,70921114
1,70921114
The--port 0
bit was nice info but I'm not sure it answers the question.
– Ash
Nov 27 '18 at 3:38
add a comment |
The--port 0
bit was nice info but I'm not sure it answers the question.
– Ash
Nov 27 '18 at 3:38
The
--port 0
bit was nice info but I'm not sure it answers the question.– Ash
Nov 27 '18 at 3:38
The
--port 0
bit was nice info but I'm not sure it answers the question.– Ash
Nov 27 '18 at 3:38
add a comment |
You can save these in a file, but you have to to put it in .ember-cli
(at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924
{
"port": 4201,
"liveReload": true,
"host": "dev.domain.org",
"live-reload-port": 49153
}
edit: you can now set these in angular-cli.json as of commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9, which is in build 1.0.0-beta.30
add a comment |
You can save these in a file, but you have to to put it in .ember-cli
(at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924
{
"port": 4201,
"liveReload": true,
"host": "dev.domain.org",
"live-reload-port": 49153
}
edit: you can now set these in angular-cli.json as of commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9, which is in build 1.0.0-beta.30
add a comment |
You can save these in a file, but you have to to put it in .ember-cli
(at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924
{
"port": 4201,
"liveReload": true,
"host": "dev.domain.org",
"live-reload-port": 49153
}
edit: you can now set these in angular-cli.json as of commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9, which is in build 1.0.0-beta.30
You can save these in a file, but you have to to put it in .ember-cli
(at the moment, at least); see https://github.com/angular/angular-cli/issues/1156#issuecomment-227412924
{
"port": 4201,
"liveReload": true,
"host": "dev.domain.org",
"live-reload-port": 49153
}
edit: you can now set these in angular-cli.json as of commit https://github.com/angular/angular-cli/commit/da255b0808dcbe2f9da62086baec98dacc4b7ec9, which is in build 1.0.0-beta.30
edited Feb 8 '17 at 15:24
answered Jan 13 '17 at 15:07
Dan MitchellDan Mitchell
540613
540613
add a comment |
add a comment |
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: ProjectNamenode_modules@angular-devkitbuild-angularsrcdev-serverschema.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
},
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
add a comment |
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: ProjectNamenode_modules@angular-devkitbuild-angularsrcdev-serverschema.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
},
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
add a comment |
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: ProjectNamenode_modules@angular-devkitbuild-angularsrcdev-serverschema.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
},
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: ProjectNamenode_modules@angular-devkitbuild-angularsrcdev-serverschema.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
},
edited Nov 26 '18 at 18:00
answered Nov 26 '18 at 17:49
Satyendra PatelSatyendra Patel
762
762
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
add a comment |
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
2
2
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
You do not want to override or change source files. angular.json is the correct way to override schema defaults, as mentioned in the accepted answer.
– Bjørn Lindner
Nov 30 '18 at 11:52
add a comment |
If your are on windows you can do it this way :
- In your project root directory, Create file run.bat
- Add your command with your choice of configurations in this file. For Example
ng serve --host 192.168.1.2 --open
- Now you can click and open this file whenever you want to serve.
This not standard way but comfortable to use (which I feel).
add a comment |
If your are on windows you can do it this way :
- In your project root directory, Create file run.bat
- Add your command with your choice of configurations in this file. For Example
ng serve --host 192.168.1.2 --open
- Now you can click and open this file whenever you want to serve.
This not standard way but comfortable to use (which I feel).
add a comment |
If your are on windows you can do it this way :
- In your project root directory, Create file run.bat
- Add your command with your choice of configurations in this file. For Example
ng serve --host 192.168.1.2 --open
- Now you can click and open this file whenever you want to serve.
This not standard way but comfortable to use (which I feel).
If your are on windows you can do it this way :
- In your project root directory, Create file run.bat
- Add your command with your choice of configurations in this file. For Example
ng serve --host 192.168.1.2 --open
- Now you can click and open this file whenever you want to serve.
This not standard way but comfortable to use (which I feel).
edited Jan 1 at 6:06
answered Jan 1 at 3:28
SankeerthSankeerth
316
316
add a comment |
add a comment |
here is what i put into package.json (running angular 6):
{
"name": "local-weather-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 5000",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Then a plain npm start will pull in the contents of start. Could also add other options to contents
add a comment |
here is what i put into package.json (running angular 6):
{
"name": "local-weather-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 5000",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Then a plain npm start will pull in the contents of start. Could also add other options to contents
add a comment |
here is what i put into package.json (running angular 6):
{
"name": "local-weather-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 5000",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Then a plain npm start will pull in the contents of start. Could also add other options to contents
here is what i put into package.json (running angular 6):
{
"name": "local-weather-app",
"version": "1.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --port 5000",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Then a plain npm start will pull in the contents of start. Could also add other options to contents
edited Jul 26 '18 at 12:24
Marian Nasry
755818
755818
answered Jul 26 '18 at 11:22
John DuggerJohn Dugger
11
11
add a comment |
add a comment |
enter image description here
Only one thing you have to do. Type this in in your Command Prompt:
ng serve --port 4021 [or any other port you want to assign eg: 5050, 5051 etc ]. No need to do changes in files.
add a comment |
enter image description here
Only one thing you have to do. Type this in in your Command Prompt:
ng serve --port 4021 [or any other port you want to assign eg: 5050, 5051 etc ]. No need to do changes in files.
add a comment |
enter image description here
Only one thing you have to do. Type this in in your Command Prompt:
ng serve --port 4021 [or any other port you want to assign eg: 5050, 5051 etc ]. No need to do changes in files.
enter image description here
Only one thing you have to do. Type this in in your Command Prompt:
ng serve --port 4021 [or any other port you want to assign eg: 5050, 5051 etc ]. No need to do changes in files.
answered Oct 4 '18 at 0:00
Shahbaz Ali KhanShahbaz Ali Khan
85
85
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37762125%2fset-default-host-and-port-for-ng-serve-in-config-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown