ionic serve displays multiple addresses and I chos

2019-01-17 03:15发布

问题:

I used ionic serve and got the below response to which I did not think twice and selected localhost. However now I want to use option 1. Ionic has remembered my selection such that ionic serve never allows me to select anymore and uses localhost...

How can I change this so that ionic serve uses the first option?

Multiple addresses available.

Please select which address to use by entering its number from the list below:

 1) 192.168.2.10 (en0)
 2) localhost

Address Selection:  

回答1:

You can use the ionic address command to update the selected address, which is available from Ionic 1.2.3.

Also, there is a file called ionic.config which you can modify with this setting. On Mac/ubuntu this file is at ~/.ionic. On a PC it can be found at c:/users/username/.ionic. Inside you'll see something like this which you can edit the ionicServeAddress value.

{
  "ank": "...",
  "versionCheck": 1413143560174,
  "ionicServeAddress": "localhost"
}


回答2:

just type ionic address command and you get the option to select your IP address again.

OR

you can explicitly select your address and port when you run ionic serve

by using the --address and --port options. Like this:

ionic serve --address IP_address --port port

example : ionic serve --address 192.168.1.129 --port 8101

Things to note

  • If you do not provide a port option with --address the default port(8100) is used instead.
  • Specifying address and port will only change the settings for that session. if you need to override saved settings, you should probably use the ionic address command instead.


回答3:

This has been fixed in version 0.6.1

Update to the latest version by running npm install -g generator-ionic and then run yo ionic inside your current project and select Y when Yeoman asks if you would like to overwrite your Gruntfile.js