Reputation: 7906
I recently started learning Ionic Framework. You can use Ionic serve
command inside the project to run a livereload server. Once in a while it asked whether server should run on localhost
or system ip
. I chose second option. Now It doesn't ask anything and directly runs on system's ip
.
How do reset this automatic behaviour?
I tried looking into serve.js
file in ionic-cli
project but no luck.
Upvotes: 18
Views: 17186
Reputation: 1000
like @user3110357 points out you can 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
--address
the default port(8100) is used instead.ionic address
command instead.Upvotes: 5
Reputation: 614
It's not necessary to edit the code. You can switch between addresses with the command ionic address
. You'll then get options like this:
Please select which address to use by entering its number from the list below:
1) 10.0.1.7 (en1)
2) localhost
Upvotes: 50
Reputation: 7906
Found a workaround. I am using this method on ubuntu so paths may be different for other os.
Go to /usr/lib/node_modules/ionic/lib/ionic
Open serve.js
with root user.
Find function called IonicTask.prototype.getAddress
Inside this function the value of variable isAddressCmd
is false. Set it to true
self.isAddressCmd = false;
save the file. Now run Ionic serve
for your project. This time it will ask for localhost
vs ip
again.
After this remove the newly added code from serve.js
otherwise ionic serve
won't work.
Upvotes: 2