Search code examples
webpacknestjswebpack-hmr

NestJS Hot Module Replacement: Invalid options object


I am using NestJS and am trying to install Hot Module replacement, following this page's instructions: https://docs.nestjs.com/recipes/hot-reload

Since I am using Nest CLI, I followed the first part of the page. However, at the moment I have to use the nest build --webpack --webpackPath webpack-hmr.config.js command, I get the following error:

Error  Invalid options object. Watch Ignore Plugin has been initialized using an options object that does not match the API schema.
 - options[0] misses the property 'paths'. Should be:
   [RegExp | string, ...] (should not have fewer than 1 item)
   -> A list of RegExps or absolute paths to directories or files that should be ignored.
 - options[1] misses the property 'paths'. Should be:
   [RegExp | string, ...] (should not have fewer than 1 item)
   -> A list of RegExps or absolute paths to directories or files that should be ignored.

Does anyone know where that could come from and how to fix it?


Solution

  • It seems the issue comes from the update from webpack 4 to webpack 5: https://github.com/nestjs/nest/issues/5667

    There are 2 solutions:

    • Wait for start-server-webpack-plugin to update and not use HMR in the mean time
    • Downgrade to webpack 4