I struggled with some of the other answers. (My setup is: I'm running npm run dev
, with webpack 3.12.0, after creating my project using vue init webpack
on an Ubuntu 18.04 virtualbox under Windows. I have vagrant configured to forward port 3000 to the host.)
npm run dev --host 0.0.0.0 --port 3000
didn't work---it still ran on localhost:8080.webpack.config.js
didn't exist and creating it didn't help either.build/webpack.dev.conf.js
(and build/webpack.base.conf.js
and build/webpack.prod.conf.js
). However, it didn't look like a good idea to modify these files, because they actually read the HOST and PORT from process.env
.So I searched about how to set process.env variables and achieved success by running the command:
HOST=0.0.0.0 PORT=3000 npm run dev
After doing this, I finally get "Your application is running here: http://0.0.0.0:3000" and I'm finally able to see it by browsing to localhost:3000
from the host machine.
EDIT: Found another way to do it is by editing the dev host and port in config/index.js
.