T
T
TinyZerg2018-03-09 13:47:36
Vue.js
TinyZerg, 2018-03-09 13:47:36

Vue-cli, how to develop under windows if everything is set up on a virtual machine?

Raised a virtual machine on VirtualBox, installed node.js, vue-cli. Created a webpack project and ran: npm run dev. Everything is fine, everything started and now you need to open a browser at localhost:8080 to view the result. But the problem is that the virtual machine with a NAT network.
I will write all the code from under windows and, accordingly, when I open the localhost browser, I see nothing on this port. I forwarded port 80 of the host machine to 8080 guest. Still nothing works. Although if we let's raise the server on node.js and express on the same port and run it on a virtual machine, then through the forwarded port everything is available in the browser at localhost:80. Why doesn't the vue-cli server work that way then? How to make the browser from under Windows see the server on vue-cli running in a virtual machine?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Tsvetkov, 2018-03-09
@yellow79

Why doesn't the vue-cli server work that way then?
you need to make this server listen to host 0.0.0.0 instead of what it listens by default (127.0.0.1)
googled this: https://github.com/vuejs/vue-cli/issues/144

T
TinyZerg, 2018-03-09
@TinyZerg

Everything worked, I used the link above. Maybe someone will come in handy:
I ​​did the following, went into the folder that vue-cli created. Found the config/index.js file. There I changed the port to 8000 (we forward it to the win machine), then we do
> export HOST=0.0.0.0 and start npm run dev
And then in the virtualbox settings we forward the http port.
Host address 127.0.0.1, port 8080, guest address 10.0.2.15, port 8000
In a browser, the site is accessible at 127.0.0.1:8080

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question