Repository navigation
Closed
Description
Upgrading to webpack 3 generates an error when used with this plugin.
Degrading to webpack 2.x or removing the plugin from config resolves the error.
Note a simular issue here:
#596
Note webpack 3 compatibility issue & PR:
#699
#704
Plugin version:
yarn list v0.24.6
└─ [email protected]
✨ Done in 1.13s.
Webpack version:
yarn list v0.24.6
└─ [email protected]
✨ Done in 1.11s.
Summarised webpack.config (i've tried a blank plugin config - no change):
var webpack = require('webpack');
var path = require('path');
var htmlWebpackPlugin = require('html-webpack-plugin');
var faviconsWebpackPlugin = require('favicons-webpack-plugin');
const root = process.cwd();
module.exports = {
resolve: {
extensions: ['.tsx', '.ts', '.js', '.json']
},
plugins: [
...
new htmlWebpackPlugin({
title: 'HiveHub',
description: 'A mapping platform for software systems',
filename: 'index.html',
template: path.join(root, 'src/index.ejs'),
inject: false,
appMountId: 'root',
initialState: 'null',
initialContent: 'null'
})
],
module: {
rules: [
...
]
}
};
Full stack dump:
ERROR in TypeError: Cannot read property 'request' of undefined
- ExternalModuleFactoryPlugin.js:37 handleExternals
[metamap]/[html-webpack-plugin]/[webpack]/lib/ExternalModuleF actoryPlugin.js:37:33
- ExternalModuleFactoryPlugin.js:46 next
[metamap]/[html-webpack-plugin]/[webpack]/lib/ExternalModuleF actoryPlugin.js:46:8
- ExternalModuleFactoryPlugin.js:59 handleExternals
[metamap]/[html-webpack-plugin]/[webpack]/lib/ExternalModuleF actoryPlugin.js:59:7
- ExternalModuleFactoryPlugin.js:79 ExternalModuleFactoryPlugin .<anonymous>
[metamap]/[html-webpack-plugin]/[webpack]/lib/ExternalModuleF actoryPlugin.js:79:5
- NormalModuleFactory.js:246 applyPluginsAsyncWaterfall
[metamap]/[webpack]/lib/NormalModuleFactory.js:246:4
- Tapable.js:196 NormalModuleFactory.applyPluginsAsyncWaterfall [metamap]/[webpack]/[tapable]/lib/Tapable.js:196:70
- NormalModuleFactory.js:230 NormalModuleFactory.create
[metamap]/[webpack]/lib/NormalModuleFactory.js:230:8
- Compilation.js:383 Compilation._addModuleChain
[metamap]/[webpack]/lib/Compilation.js:383:17
- Compilation.js:465 Compilation.addEntry
[metamap]/[webpack]/lib/Compilation.js:465:8
- SingleEntryPlugin.js:22 SingleEntryPlugin.<anonymous>
[metamap]/[html-webpack-plugin]/[webpack]/lib/SingleEntryPlug in.js:22:15
- Tapable.js:229 Compiler.applyPluginsParallel
[metamap]/[webpack]/[tapable]/lib/Tapable.js:229:14
- Compiler.js:505
[metamap]/[webpack]/lib/Compiler.js:505:8
- Tapable.js:131 Compiler.applyPluginsAsyncSeries
[metamap]/[webpack]/[tapable]/lib/Tapable.js:131:46
- Compiler.js:498 Compiler.compile
[metamap]/[webpack]/lib/Compiler.js:498:7
- Compiler.js:284 Compiler.runAsChild
[metamap]/[webpack]/lib/Compiler.js:284:7
- compiler.js:70
[metamap]/[html-webpack-plugin]/lib/compiler.js:70:19
Reacted by Gerard Chin, Patrick Gotthardt, Anton, Anders Emil Rønning, Georgios Lolos, Sondre Naustdal, Dziamid, Valerii Vasin, Hendrik Werner, Dawid Karabin and 18 more
Metadata
Metadata
Assignees
Labels
No labels
Activity
gerardmrk commentedon Jun 20, 2017
Sorry for this useless comment that does not contribute to this issue whatsoever, but just wanted to confirm that I too have this exact same issue with Webpack 3 (just in case this issue is deemed a one-off configuration error on OP's end).
jantimon commentedon Jun 20, 2017
Did you already had time to take a look for the reason?
mcrawshaw commentedon Jun 20, 2017
No sorry, would like to help, but not at all sure where to start.
ValeriiVasin commentedon Jun 20, 2017
Having the same issue. Seems html-webpack-plugin is not ready yet for webpack 3
mastilver commentedon Jun 20, 2017
@hulkish @yuffiy @yveskaufmann Do you think you can help here as it sounds like you managed to make webpack@3 working with
html-webpack-plugin?mastilver commentedon Jun 20, 2017
Do you think any of you can provide a repo to reproduce it?
On my project I only get a warning on
npm installbut except that everything is running fine...HairyRabbit commentedon Jun 20, 2017
@mastilver ❤️ Change dir to
node_modules/html-webpack-pluginthen runnpm install webpack extract-text-webpack-pluginmaybe works fine.Or use my forked repo until the PR merged.
mattlewis92 commentedon Jun 20, 2017
I'm getting this as well, it seems to be a bug with yarn whereby a dependency (
webpack-stream) has a hard dependency on webpack 1 and it's getting copied into other dependencies that depend on webpack as peer dependencies:The only solution I've found so far is to switch from yarn to npm5
joseds commentedon Jun 20, 2017
I can confirm this, I also switched temporarily from yarn to npm, sorry, don't have the time to investigate further right now.
mastilver commentedon Jun 20, 2017
@mattlewis92 @joseds To clarify myself, the warning I got from npm/yarn is expected. (as the peerDependency doesn't allow webpack@3 yet)
About the issue @mcrawshaw raises: I can't reproduce it on my project
mattlewis92 commentedon Jun 20, 2017
@mastilver I was referring to how to reproduce the error with
ERROR in TypeError: Cannot read property 'request' of undefined. When there is a dependency that depends on webpack v1 (as an actual dependency not a peer dependency) then yarn is putting webpack v1 as a dependency ofhtml-webpack-pluginwhich is throwing then throwing that error as its requiring code from webpack v1, but then trying to use it with a webpack v3 instance.tl;dr it's an issue with yarn, updating the peer dependency to allow webpack v3 might fix the issue.
mcrawshaw commentedon Jun 20, 2017
Yep, I can confirm, it's a packaging issue. Using npm 5.0.3 resolves my issue.
My npm list looks similar to you @mattlewis92.
Mark.
damianobarbati commentedon Jun 21, 2017
is a fix coming any soon? looks like a trivial change right? thanks guys!
ErikFontanel commentedon Jun 21, 2017
I had the same issue after upgrading to Webpack 3. And I too can confirm using npm 5.0.3 instead of yarn fixes the issue.
mastilver commentedon Jun 21, 2017
@damianobarbati I think are going to hold off until
extract-text-webpack-plugin@3is out, we don't want to release something unless we are 100% sure it's not going to break any of the features we currently supportUntil that is done you can use directly either: #706 or #707
@jantimon Can you confirm this is the right approach and I'm not saying BS? ;)
damianobarbati commentedon Jun 24, 2017
@mastilver do you think this is going to happen any soon?
mcrawshaw commentedon Jun 25, 2017
Can confirm as resolved.
smoliakov commentedon Aug 4, 2017
Unfortunately, the same issue, after updating to:
Output (
yarn start,"start": "webpack-dev-server --inline --hot")Node modules reinstall didn't help.
NPM 5.3.0 also didn't work.
mastilver commentedon Aug 4, 2017
@AlexeySmolyakov Did you check: #683 (comment)
smoliakov commentedon Aug 4, 2017
@mastilver thank you so much!
Removing
yarn.lockis the key.martinpinto commentedon Dec 29, 2017
I can confirm that updating
"webpack": "3.4.1", "html-webpack-plugin": "2.30.1", "html-loader": "0.5.0", "webpack-dev-server": "2.6.1"to the latest versions (and explicitly adding them to package.json) fixes the problem. Why do every
npm ihave to lead to breaking changes? Removing all "~"'sand "^"'s from my package.json!lock commentedon May 31, 2018
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.