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.

webpack-dev-server breaks on changing folder structure or renaming files and requires restart

See original GitHub issue

Do you want to request a feature or report a bug? In my opinion this is a bug because it was working in older versions of webpack.

What is the current behavior? When I rename some file or change folder structure the webpack starts showing “…Module build failed: Error: ENOENT: no such file or directory,…”, and it doesn’t recover from that, so I have to restart webpack dev server in order to have the hot reloading working again. The documentation suggests explicitly setting watchOptions but didn’t work. Is there some cache invalidation that I have to configure or…? If the current behavior is a bug, please provide the steps to reproduce. Described above and my webpack dev configuration is:

const path = require('path');
const webpack = require('webpack');
const config = require('../config');

module.exports = {
  entry: [
    'react-hot-loader/patch',
    'webpack-dev-server/client?http://localhost:9001',
    'webpack/hot/only-dev-server',
    path.join(config.projectPath, 'src', 'reactApp'),
  ],
  output: {
    path: path.join(config.projectPath, 'assets'),
    filename: 'bundle.js',
    publicPath: 'http://localhost:9001/',
  },
  devtool: 'cheap-module-eval-source-map',
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NamedModulesPlugin(),
    new webpack.DefinePlugin({
      __DEV__: true,
      'process.env.NODE_ENV': JSON.stringify('development'),
    }),
    new webpack.ProvidePlugin({ Promise: 'bluebird' }),
  ],
  resolve: {
    extensions: ['.js', '.jsx'],
  },
  module: {
    noParse: /node_modules\/aws-sdk\/dist\/aws-sdk/,
    rules: [...],
  },
};

And my server.js file:

const devServer = new WebpackDevServer(webpack(webpackConfig), {
  hot: true,
  watchOptions: { poll: true },
  host: 'localhost',
  port: 9001,
  publicPath: 'http://localhost:9001/',
  compress: true,
  noInfo: true,
  stats: { colors: true, errorDetails: true },
  headers: { 'Access-Control-Allow-Origin': '*' },
  historyApiFallback: true,
});

devServer.listen(9001);

What is the expected behavior? Like in older versions of webpack, the dev-server should not crash, but pick up the new folder structure. If this is a feature request, what is motivation or use case for changing the behavior? having to manually restart dev server on any file structure change and wait for it to build a bundle is not useful at all. Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System. I’m using webpack 3.3.0 and webpack-dev-server 2.6.1, latest Chrome browser and Ubuntu 14.04.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:23
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

12reactions
sokracommented, Jan 15, 2019

This will be fixed in webpack 5

4reactions
palnescommented, Sep 5, 2017

It really would be nice if it was possible to restart the build from scratch without exiting the watcher (think Ctrl-F5 for the watcher). Bonus points if it can re-parse the config it was started with as well. 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

webpack --watch isn't compiling changed files - Stack Overflow
The recommended fixes from the above link are: rebooting the computer; checking the disk and repairing permissions via Disk Utility; adding the folder...
Read more >
All You Need to Know about Webpack in Examples - Medium
What topics this article covers: 1. Simplest project and Webpack installation;; 2. Configuration file;; 3. Regenerate bundle on file save;; 4.
Read more >
Fix Cannot Rename Folders In Windows 11/10 - YouTube
This Tutorial Helps to Fix Cannot Rename Folders In Windows 11/1000:00 Intro00:11 Method 1 - Restart Windows Explorer00:24 Method 2 - System ...
Read more >
Upgrade Guide - Quasar Framework
Use Quasar boot files for any pre-mounting app routines. ... You'll need to adapt to the breaking changes of the new versions of...
Read more >
Webpack or Browserify & Gulp: Which Is Better? - Toptal
Modern web applications require more effort from the developer to adopt an ... nodemon would restart the running process on any JS file...
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