html-webpack-plugin: Cannot resolve module html-webpack-plugin/lib/loader.js after upgrade to 2.25.0

Hi, after upgrade to version 2.25.0 (I have the same problem with version 2.26.0) I got an error:

ERROR in   EntryModuleNotFoundError: Entry module not found: Error: Cannot resolve
module   'html-webpack-plugin/lib/loader.js'

I wasn’t able to find, what change caused this problem.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 4
  • Comments: 19 (4 by maintainers)

Most upvoted comments

I had a similar issue mentioned here but with the plugin not being able to find lodash.js. You can expand the error by using the --display-error-details flag on webpack - and I could see that it was complaining that it couldn’t find lodash.js.js. Anyway I eventually figured out what had happened.

It was being caused by this config item:

resolve: {
  extensions: ['', '.js', '.jsx', '.json', '.css'],
},

In my webpack 1.x config the resolve.extensions config item has an empty string as the first property, which means it will find e.g. a filename of lodash.js in the order of lodash.js, lodash.js.js, lodash.jsx etc.

In webpack 2.x the empty string isn’t allowed, meaning the plugin has to give it a filename of lodash only and it will find it in the order of lodash.js, lodash.jsx etc

I’m not sure if this helps here but it solved my problem (in this case I was actually downgrading from webpack 2 to 1)

I just discovered the following (inside webpack.config.js):

Does not work: resolveLoader: { root: paths.ownNodeModules, moduleTemplates: ['*-loader'] }

Works: resolveLoader: { root: paths.ownNodeModules }

Again, I had copied this from create-react-app and have no idea why moduleTemplates is being modified from the default.