webpack错误:子编译失败:无法读取未定义的属性“ sort”:

时间:2019-06-20 18:23:07

标签: webpack-dev-server html-webpack-plugin

从版本2迁移到Webpack版本4时,我看到以下未定义的错误。似乎找不到问题。

下面是我的webpack配置

    new HtmlWebpackPlugin({
        template: './src/app/sample-error.ejs',
        chunksSortMode: 'dependency',
        filename: 'jpmol-error.html',
        chunks: [
            'polyfills',
            'styles-jpmol',
            'main-jpmol-error'
        ]
    }),

在尝试启动Webpack开发服务器时,我得到以下错误ID。

ERROR in   Error: Child compilation failed:
  Cannot read property 'sort' of undefined:
  TypeError: Cannot read property 'sort' of undefined

  - compiler.js:79 
    [action-center-ui]/[html-webpack-plugin]/lib/compiler.js:79:16

   - Compiler.js:306 
      [action-center-ui]/[webpack]/lib/Compiler.js:306:11

   - Compiler.js:631 
      [action-center-ui]/[webpack]/lib/Compiler.js:631:15


  - Hook.js:154 AsyncSeriesHook.lazyCompileHook
   [action-center-ui]/[tapable]/lib/Hook.js:154:20

   - Compiler.js:628
   [action-center-ui]/[webpack]/lib/Compiler.js:628:31


  - Hook.js:154 AsyncSeriesHook.lazyCompileHook
    [action-center-ui]/[tapable]/lib/Hook.js:154:20

  - Compilation.js:1325
   [action-center-ui]/[webpack]/lib/Compilation.js:1325:35


  - Hook.js:154 AsyncSeriesHook.lazyCompileHook
   [action-center-ui]/[tapable]/lib/Hook.js:154:20

 - Compilation.js:1316
    [action-center-ui]/[webpack]/lib/Compilation.js:1316:32


  - Hook.js:154 AsyncSeriesHook.lazyCompileHook
    [action-center-ui]/[tapable]/lib/Hook.js:154:20

   - Compilation.js:1311
     [action-center-ui]/[webpack]/lib/Compilation.js:1311:36

   ERROR in chunk styles-jpmol [entry]
      Cannot read property 'sort' of undefined
       Child html-webpack-plugin for "jpmol-error.html":
      1 asset
         Entrypoint undefined = jpmol-error.html
        [./node_modules/html-webpack-plugin/lib/loader.js!./src/app/jpmol- 
        error.ejs] 844 bytes {0} [built]
        [./node_modules/lodash/lodash.js] 527 KiB {0} [built]
        [./node_modules/webpack/buildin/global.js] 
       (webpack)/buildin/global.js 472 bytes {0} [built]
        [./node_modules/webpack/buildin/module.js] 
        (webpack)/buildin/module.js 497 bytes {0} [built


   ERROR in chunk 0 [entry]
    Cannot read property 'sort' of undefined
  Child html-webpack-plugin for "capture.html":
     1 asset
    Entrypoint undefined = capture.html
     [./node_modules/html-webpack- 
   plugin/lib/loader.js!./src/app/capture.ejs] 840 bytes {0} [built]
     [./node_modules/lodash/lodash.js] 527 KiB {0} [built]
     [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 
     472 bytes {0} [built]
     [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 
    497 bytes {0} [built]

     ERROR in chunk 0 [entry]
     Cannot read property 'sort' of undefined

我更新了所有webpack插件以使其与版本4一致,但无法克服此错误。

0 个答案:

没有答案