question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hot reloading no longer works after switching back to default WebpackDevServer client

See original GitHub issue

I had to switch to the default WebpackDevServer client because it allowed me to specify the server address. I’ve found that doing so breaks the hot reloading functionality completely.

I have another project created by an older version of create-react-app (sorry, can’t remember what version) but it’s using the same version of webpack-dev-server and configuration and works fine. That’s with the same node/npm.

Can you reproduce the problem with latest npm?

I’m currently using the latest node and npm available (node 6.10.0 / npm 3.10.10)

Description

Hot reload does not work with the default webpack-dev-server client

Expected behavior

Hot reload should work with the default webpack-dev-server client.

Actual behavior

There is no websocket connection attempt made to the address specified (http://localhost:3000/), hence hot reload can never be triggered by a code change.

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (I’ve ejected)
  2. node -v: 6.10.0
  3. npm -v: 3.10.10

Then, specify:

  1. Operating system: Windows 7 x64
  2. Browser and version: Chromium, Firefox, Vivaldi

Reproducible Demo

Steps to reproduce:

With the latest node/npm/yarn

  • npm install -g create-react-app

  • create-react-app hotreload

  • cd hotreload

  • yarn start

  • Test that hot reload works by editing App.js

  • Stop the server

  • yarn eject

  • confirm Y

  • yarn start

  • Test that hot reload works by editing App.js

  • edit hotreload/config/webpack.config.dev.js

  • find line 43: require.resolve('react-dev-utils/webpackHotDevClient'),

  • comment it out and replace it with require.resolve('webpack-dev-server/client') + '?http://localhost:3000/',

  • yarn start

  • Test that hot reload works by editing App.js

  • Hot reload no longer works

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
twigcommented, Mar 5, 2017

Alright I’ve uploaded an example up here: https://github.com/twig/brokenhotreload/

There is only one change made after I ejected from create-react-app and it’s in this commit.

You should be able to get up and running by checking it out and running yarn, then yarn start after it’s done.

0reactions
twigcommented, Mar 5, 2017

thanks for the prompt and detailed responses guys!

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack-dev-server hot reload not working - Stack Overflow
It seems webpack-dev-server gets confused when it sees dist/bundle.js in the html file and doesn't hot replace it, even though webpack.config.js is configured ......
Read more >
Why webpack-dev-server Live-Reload Is Not Working - Medium
When I modify javascript files, I have to manually run Webpack CLI to see changes to bundle.js in the local filesystem, and bundle.js...
Read more >
Hot Module Replacement - webpack
You can use the CLI to modify the webpack-dev-server configuration with the following command: webpack serve --hot-only . Now let's update the index....
Read more >
Getting Started · React Hot Loader - Dan gaearon
React Hot Loader is a plugin that allows React components to be live reloaded without the loss of state. It works with Webpack...
Read more >
webpack-dev-server
To the use inline mode specify --inline on the command line (you cannot specify it in the configuration). This adds the webpack-dev-server client...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found