Error after upgrading to latest webpack 2.1 beta #1236

Closed
opened 2025-08-09 17:19:22 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @Maarten88 on 11/24/2016

In a project that uses Microsoft.AspNetCore.ReactServices I upgraded webpack to the latest beta (that I read will turn final soon) and got this error:

Exception: Call to Node module failed with error: TypeError: Cannot read property 'forEach' of undefined
at Object.addReactHotModuleReplacementBabelTransform (node_modules\aspnet-webpack-react\HotModuleReplacement.js:3:33)
at attachWebpackDevMiddleware (node_modules\aspnet-webpack\WebpackDevMiddleware.js:61:38)

this happens on the line:

app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
    HotModuleReplacement = true,
    ReactHotModuleReplacement = true
});

I think this is caused by the renaming (in webpack 2.1 beta 23) of module loaders to module rules, which I had to change in my webpack.config.

The line that causes the error is:

webpackConfig.module.loaders.forEach(function (loaderConfig) {

If I change this line to

webpackConfig.module.rules.forEach(function (loaderConfig) {

Everything seems to work as before.

*Originally created by @Maarten88 on 11/24/2016* In a project that uses Microsoft.AspNetCore.ReactServices I upgraded webpack to the latest beta (that I read will turn final soon) and got this error: Exception: Call to Node module failed with error: TypeError: Cannot read property 'forEach' of undefined at Object.addReactHotModuleReplacementBabelTransform (node_modules\aspnet-webpack-react\HotModuleReplacement.js:3:33) at attachWebpackDevMiddleware (node_modules\aspnet-webpack\WebpackDevMiddleware.js:61:38) this happens on the line: app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true, ReactHotModuleReplacement = true }); I think this is caused by the renaming (in webpack 2.1 beta 23) of module loaders to module rules, which I had to change in my webpack.config. The line that causes the error is: webpackConfig.module.loaders.forEach(function (loaderConfig) { If I change this line to webpackConfig.module.rules.forEach(function (loaderConfig) { Everything seems to work as before.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1236
No description provided.