react-refresh-webpack-plugin: Cannot read property 'mode' of undefined

After adding this plugin to an ejected CRA project I get:

Cannot read property 'mode' of undefined

Are we assuming some particular webpack version?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 17 (7 by maintainers)

Most upvoted comments

I reproduced this by adding the Webpack conf, in webpack.config, in resolve.plugins section, not in plugins section

resolve: {
  plugins: [
    new ReactRefreshWebpackPlugin(),
  ],
}

It’s working by putting the configuration in webpack plugins section.

Well I don’t think this is something that we have to deal with … ? All plugins could fail if you use them as resolver plugins?

Well I don’t think this is something that we have to deal with … ? All plugins could fail if you use them as resolver plugins?

I totally agree with you, you should not handle this case, it’s a configuration error made by us. I added this comment to help anybody who, like me, made this mistake and look for a solution here 😃

I reproduced this by adding the Webpack conf, in webpack.config, in resolve.plugins section, not in plugins section

resolve: {
  plugins: [
    new ReactRefreshWebpackPlugin(),
  ],
}

It’s working by putting the configuration in webpack plugins section.