Getting npm run watch to work with Laravel and Laragon
Hi, newbie question! I am trying to setup a project using laravel as backend and vuejs as front end.
I am having issues when I run npm run watch, it gets compiled ok but I cannot access for example my-project-example.dev:8080 which is the local dev server. Should I try to change the webpack dev default server port or is there any other solution?
@lorenzo1975 : You should show an image of your console so we can identify issue and help you.
Hello @leokhoa thanks for you support. Here I have attached of the result build with npm run watch:
From running command npm run watch:
Here the build result
I can see my changes reflected in the browser at the project address, but shouldn't I have two running web servers? One from js at project.dev:8080 and the other one from php / laragon at project.dev ?
I will try with a full spa test with vue-router to see if I am actually taking over php, while testing this I am following a very simple tutorial and it does not use vue-rotuer, so I am still returning welcome.blade.php as root path. I was just expecting with npm run watch to see also a dev server at :8080
Did you try
npm run dev?
npm run dev
Hi, yes I did and it builds correctly...
but I still get no response from :8080, all works fine at .dev see my snapshot of network tab on example.dev
and on example.dev:8080
Now in settings I have not touched anything, so I guess nginx is not active:
@lorenzo1975 : If you check Nginx, you surely can run at 8080
So, you did nothing wrong. You run
npm run watchto ask Node.js auto reload for you if there is any file change.
Apache serves your PHP at port 80. If you need port 8080, you can change Apache's port or activate Nginx.
@leokhoa I mentioned being a newbie! But I am still a bit confused, when I run npm run watch on a vuejs project for example I get a built in dev server running...correct? It uses by default port 8080.
If I check nginx I sure serve the site via nginx, but my question / doubt is still there, what happens to the webpack dev-server? Is it running in the background? For a simple tutorial like the one I was following is fine, but what about when I try (I will soon) try to setup a full single page app and just use laravel as the backend, in this case I will want to have the site running on :8080 via node, is this correct?
P.S. Thanks for the amazing work on this community, I really enjoy laragon by the way.
Ok, getting closer...! I changed apache to 8888, now I can run both at same time webpack dev server at 8080 and php at 8888, I am getting addicted...:)