How to run angular-cli from a Vagrant box?

I installed angular-cli with node v6.5.0 and npm v3.10.3 in my firewall (scotch tape). After running 'ng serve -port 4201', I see that the build was successful and that the application now runs on http: // localhost: 4201 /

However, I cannot just use the above address because I work in a virtual machine. I tried to add "127.0.0.1-00-00201" to the hosts file on the host machine, but cannot get anything to work.

thanks

+6
source share
4 answers

Vagrant (VM) does not raise file change events. This error is reported to the VirtualBox community and installed in will not be fixed. At the moment, working with Angular 2 through Vagrant is not possible. See this issue on GitHub for an appropriate discussion of this issue.

+2
source

Run ng serve as follows:

 ng serve --host 0.0.0.0 

This will cause the server in your vagrant machine to be accessible externally using its ip (mine is 192.168.10.10 using homestead) and the default is 4200 for angular serve (http://192.168.10.10-00-00-00-00).

Additional Information:

127.0.0.1 is a loopback address, so if you assign this IP address (or local host) to your server configuration, it is not accessible from other network interfaces, so you cannot access it outside of the VM. If you connect your server with 0.0.0.0, it is available for all interfaces

+15
source

You need to add some configuration to Vagrantfile.

To access the site, add these lines (this helped me):

 config.vm.network "private_network", ip: "192.168.100.100" config.vm.network "forwarded_port", guest: 4200, host: 4200 config.vm.network "forwarded_port", guest: 49152, host: 49152 

You can access the site: http : //192.168.100.100-00-00200/

+6
source

There are several ways to do this, for myself, what I did, first I installed VMware (virtual machine), make sure that you get the latest version.

After successful installation of vm, download nodes and roaming. open cmd -> find it in the folder where your tramp is located, The next type is in Vagrant up , and it should work. If you have any problems. try entering this vagrant ssh [name | id] [- extra_ssh_args] ..

Hope that helps

0
source

All Articles