Html-webpack-plugin: TypeError: Cannot read property '0' of undefined

Created on 3 Mar 2017  路  10Comments  路  Source: jantimon/html-webpack-plugin

Hi all I'm having issues using this plugin in my webpack build.
I'm using Webpack 2.2.0 and html-webpack-plugin 2.28.0 and yarn 0.20.3

This is the full error

ERROR in   TypeError: Cannot read property '0' of undefined

  - ExternalModuleFactoryPlugin.js:18 ExternalModuleFactoryPlugin.<anonymous>
    [phoenix-wallet]/[webpack]/lib/ExternalModuleFactoryPlugin.js:18:38

  - NormalModuleFactory.js:159
    [lib]/[webpack]/lib/NormalModuleFactory.js:159:3

  - Tapable.js:75 NormalModuleFactory.applyPluginsAsyncWaterfall
    [lib]/[webpack]/[tapable]/lib/Tapable.js:75:69

  - NormalModuleFactory.js:144 NormalModuleFactory.create
    [lib]/[webpack]/lib/NormalModuleFactory.js:144:8

  - Compilation.js:356 Compilation.process [as _addModuleChain]
    [lib]/[webpack]/lib/Compilation.js:356:16

  - Compilation.js:424 Compilation.process [as addEntry]
    [lib]/[webpack]/lib/Compilation.js:424:7

  - SingleEntryPlugin.js:24 Compiler.compiler.plugin
    [phoenix-wallet]/[webpack]/lib/SingleEntryPlugin.js:24:16

  - Tapable.js:107 Compiler.applyPluginsParallel
    [lib]/[webpack]/[tapable]/lib/Tapable.js:107:14

  - Compiler.js:394 Compiler.compile
    [lib]/[webpack]/lib/Compiler.js:394:7

  - Compiler.js:203 Compiler.runAsChild
    [lib]/[webpack]/lib/Compiler.js:203:7

  - compiler.js:70
    [phoenix-wallet]/[html-webpack-plugin]/lib/compiler.js:70:19

  - debuggability.js:300 Promise._execute
    [phoenix-wallet]/[html-webpack-plugin]/[bluebird]/js/release/debuggability.js:300:9

  - promise.js:481 Promise._resolveFromExecutor
    [phoenix-wallet]/[html-webpack-plugin]/[bluebird]/js/release/promise.js:481:18

  - promise.js:77 new Promise
    [phoenix-wallet]/[html-webpack-plugin]/[bluebird]/js/release/promise.js:77:14

  - compiler.js:69 Object.compileTemplate
    [phoenix-wallet]/[html-webpack-plugin]/lib/compiler.js:69:10

  - index.js:47 Compiler.<anonymous>
    [phoenix-wallet]/[html-webpack-plugin]/index.js:47:40

  - Tapable.js:107 Compiler.applyPluginsParallel
    [lib]/[webpack]/[tapable]/lib/Tapable.js:107:14

  - Compiler.js:394 Compiler.compile
    [lib]/[webpack]/lib/Compiler.js:394:7

  - Compiler.js:173 Compiler.<anonymous>
    [lib]/[webpack]/lib/Compiler.js:173:9

  - Compiler.js:302 Compiler.readRecords
    [lib]/[webpack]/lib/Compiler.js:302:10

  - Compiler.js:170 Compiler.<anonymous>
    [lib]/[webpack]/lib/Compiler.js:170:8

  - Tapable.js:67 Compiler.next
    [lib]/[webpack]/[tapable]/lib/Tapable.js:67:11

  - NodeEnvironmentPlugin.js:23 Compiler.<anonymous>
    [lib]/[webpack]/lib/node/NodeEnvironmentPlugin.js:23:3

  - Tapable.js:69 Compiler.next
    [lib]/[webpack]/[tapable]/lib/Tapable.js:69:14

  - CachePlugin.js:22 Compiler.<anonymous>
    [lib]/[webpack]/lib/CachePlugin.js:22:58

  - Tapable.js:71 Compiler.applyPluginsAsync
    [lib]/[webpack]/[tapable]/lib/Tapable.js:71:13

  - Compiler.js:167 Compiler.run
    [lib]/[webpack]/lib/Compiler.js:167:7

  - webpack.js:188 processOptions
    [lib]/[webpack]/bin/webpack.js:188:12

  - webpack.js:192 Object.<anonymous>
    [lib]/[webpack]/bin/webpack.js:192:1

And this is my webpack config as of now. Doesn't get much more basic than this

/* eslint complexity: ["off"] */
var path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: './index.js',
    output: {
        filename: 'bundle.js',
        path: path.resolve(__dirname, 'dist')
    },

    plugins: [
        new HtmlWebpackPlugin({}),
    ]
};

The index.js file just contains a simple console.log() statement for now.
When I comment out HtmlWebpackPlugin({}) the build runs ok. Any idea whats happening?

Most helpful comment

Local installation of Webpack and Webpack-Dev-Server fixed this error for me.

All 10 comments

馃憤 I got this error too, similarly simple webpack config and also just a console.log in my entry file.

@mikefisher84 I was using Webpack 2.x and downgraded it to 1.13.2 (was using that version in an old project so I just tried with that version) and that fixed the problem

Local installation of Webpack and Webpack-Dev-Server fixed this error for me.

@sebastiancarlsson I downgraded it to 1.7.0 and it worked.Thank you!

Any movement on getting this fixed for use with webpack 2.x?

I've been using this plugin alongside webpack 2.2.0-rc.2 and above, I never experience any issues

Can any of you give me a git repository that reproduce that issue?

Closing this as I didn't hear from anyone

Feel free to reach out if it's still an issue

Anyone else having this issue with create-react-app?

EDIT: Upgraded yarn to 0.24.5 and react-scripts to canary. Fixed. see https://github.com/facebookincubator/create-react-app/issues/2069

Don't use canary please. Skip straight to latest 1.0.x release.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GerkinDev picture GerkinDev  路  3Comments

lonelydatum picture lonelydatum  路  3Comments

yyx990803 picture yyx990803  路  4Comments

klinki picture klinki  路  3Comments

mmjamal picture mmjamal  路  3Comments