【问题标题】:Cannot read property 'tapAsync' of undefined at ExternalModuleFactoryPlugin.js:30无法读取 ExternalModuleFactoryPlugin.js:30 处未定义的属性“tapAsync”
【发布时间】:2020-07-23 23:50:12
【问题描述】:

我正在开发一个反应项目,我想设置故事书。我收到以下错误,我无法使用 webpack-5-beta-14 升级我的故事书(5.3.7)。

/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js:30

normalModuleFactory.hooks.factorize.tapAsync(
                                   ^

TypeError: Cannot read property 'tapAsync' of undefined

我在控制台记录了 normalModuleFactory 提供的钩子,这就是我得到的,

{ resolver:
   SyncWaterfallHook {
     _args: [ 'resolver' ],
     taps: [ [Object] ],
     interceptors: [],
     call: [Function: lazyCompileHook],
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined },
  factory:
   SyncWaterfallHook {
     _args: [ 'factory' ],
     taps: [ [Object] ],
     interceptors: [],
     call: [Function: lazyCompileHook],
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined },
  beforeResolve:
   AsyncSeriesWaterfallHook {
     _args: [ 'data' ],
     taps: [ [Object] ],
     interceptors: [],
     call: undefined,
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined },
  afterResolve:
   AsyncSeriesWaterfallHook {
     _args: [ 'data' ],
     taps: [ [Object], [Object] ],
     interceptors: [],
     call: undefined,
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined },
  createModule:
   SyncBailHook {
     _args: [ 'data' ],
     taps: [],
     interceptors: [],
     call: [Function: lazyCompileHook],
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined },
  module:
   SyncWaterfallHook {
     _args: [ 'module', 'data' ],
     taps: [],
     interceptors: [],
     call: [Function: lazyCompileHook],
     promise: [Function: lazyCompileHook],
     callAsync: [Function: lazyCompileHook],
     _x: undefined }

normalModuleFactory 对象不包含任何称为 factorize 的钩子,它只有工厂钩子。我去检查了 webpack github repo,它有 factorize 钩子。我不知道它在哪里被覆盖。任何意见都将帮助我摆脱这个问题。

【问题讨论】:

    标签: javascript node.js reactjs webpack storybook


    【解决方案1】:

    对我来说问题是,我使用的是 webpack 5 beta,故事书使用的是 webpack 4,它是 webpack 4 和 5 之间的子句。

    【讨论】:

    • 给自己答案!
    • 您能分享一下您是如何更改配置的吗?
    【解决方案2】:
    "dependencies": {
      "webpack": "^4.0.0"
    }
    

    将 webpack 版本修复为 4,将解决此问题。

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,就像上面提到的@Saravanan。这是一个 Webpack 问题。

      但是,当我升级到 Webpack5 时,React 使用的 Webpack 版本不匹配,所以我也升级到了 React17。

      Here 是我关注的解决问题的文章。

      【讨论】:

        猜你喜欢
        • 2023-03-30
        • 2021-04-17
        • 1970-01-01
        • 2019-04-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-04-06
        • 2021-03-03
        相关资源
        最近更新 更多