New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot change the HMR port easily for multiple projects running simultaneously #2308
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm running into problems with this. When I try to pass in an HMR port, it gives an error:
I think it's missing from /bin/cli.js. Environment
|
Try |
When I try that, I still get an error:
This is with It doesn't appear to be a valid option:
|
For what its worth, this worked for me: |
Running this on different ports with two projects simultaneously ends up with one of them refreshing constantly. I would still love to find a solution to this as it could completely remove the daily task(s) of messing with windows when switching projects. Edit Found the solution for my situation.
|
@tominal you can actually run something like |
npm list --depth=0
)node -v
): 11.15.0npm -v
): 6.7.0Description:
I think that HMR is not working as it should. If you run the script
npm run hot
without providing a port argument, it will bind 8080 port. It is good for a single project. A lot of times I have 3-5 projects at once, solaravel-mix
is not good enough for my work, yet. I'm currently using my own gulp+webpack combination, but I think it would be much better to use something popular likelaravel-mix
, so let's see what's my problem.Steps To Reproduce:
php artisan serve
andnpm run hot
php artisan serve
, now he detects, that the port 8000 is occupied, os it bind 8001 - so far so goodnpm run hot
won't work, because it just "die" when the port 8080 is occupiednpm run hot -- --port=8081
, hooray - it works!Here is the screenshot:
I have created 2 same laravel projects from scratch with a simple change in the app.scss - I have changed their body's background to see the effect:
When I look into the browser I see both projects having the same background:
The reason is simple - both projects' webpack are served from the same host.
The solution is also theoretically simple, just add this into the
webpack.mix.js
file:Now I re-run the script for
test2
project and it seems to be working well, even both projects now have different backgrounds!But this is not a good solution.
Why? Well, because you are changing a JS file, which is also in the project's repository and used by other coworkers. We can change a port for every project we create, but it's still a solution just for a single team. If you want to work on something your own/private or even for a different team, a random HMR port can be set in both teams for different projects, and it will cause a problem. Maybe it's not a common problem, but when this will occur, there will be no fix.
What is a good solution then?
Option 1: make it possible to change HMR port in run command, for example:
npm run hot -- --port=8081 --hmr-port=8081
, since every developer is running this command separately, so there is no change for other developers.Option 2: check for the occupied port, if it is occupied, then add +1 and so on, until there is a free port, which will add developers much better UX when running HMR. Artisan's serve is a good example.
Thank you if you will look at it and sorry for a long text, hope it is clear enough.
The text was updated successfully, but these errors were encountered: