【问题标题】:ProgressPlugin TypeError: Cannot read property 'tap' of undefinedProgressPlugin TypeError:无法读取未定义的属性“点击”
【发布时间】:2019-04-13 03:36:21
【问题描述】:

我在编译过程中遇到错误。似乎对 webpack 中的 ProgressPlugin 不太满意:

/node_modules/webpack/lib/ProgressPlugin.js:205
    compilation.hooks.addEntry.tap("ProgressPlugin", entryAdd);

TypeError: Cannot read property 'tap' of undefined

我知道 webpack 4 的插件最近发生了一些变化。似乎 addEntry, failedEntry, succeedEntry 不在编译挂钩的文档中 - https://webpack.js.org/api/compilation-hooks/ - 我错过了什么吗?

我的 package.json 部门:

"amazon-cognito-identity-js": "^2.0.30",
"array-move": "^1.0.0",
"aws-sdk": "^2.352.0",
"babel-loader": "^8.0.4",
"babel-plugin-styled-components": "^1.8.0",
"fuse.js": "^3.3.0",
"grid-styled": "^5.0.2",
"json-cycle": "^1.3.0",
"lodash": "^4.17.11",
"next": "^7.0.2",
"next-routes": "^1.4.2",
"node-fetch": "^2.2.1",
"path-match": "1.2.4",
"rc-time-picker": "^3.4.0",
"react": "^16.6.1",
"react-autocomplete": "^1.8.1",
"react-copy-to-clipboard": "^5.0.1",
"react-day-picker": "^7.2.4",
"react-dom": "^16.6.1",
"react-modal": "^3.6.1",
"react-places-autocomplete": "^6.1.3",
"react-scripts": "^1.1.5",
"react-spinners": "^0.4.7",
"react-stripe-checkout": "^2.6.3",
"react-stripe-elements": "^2.0.1",
"refunk": "^3.0.1",
"styled-system-html": "^2.0.2",
"webpack": "^4.25.1",
"webpack-dev-server": "^3.1.10"

【问题讨论】:

  • 你有 react-scripts 和 webpack,所以你有 2 个 webpack。请查看您的 node_modules 正在安装哪个版本的 webpack!它应该 > 4.25
  • 如果我将 webpack 4.25.1 作为显式依赖项删除,它会安装 webpack 4.19.1,它具有不同版本的 ProgressPlugin,没有 addEntry、failedEntry、succeedEntry 引用,然后编译美好的。看起来 ProgressPlugin 是最近才更新的。
  • 是的,没错!确切地说是 2 周前。
  • 需要解决什么问题?,我也遇到了同样的问题

标签: webpack


【解决方案1】:

你有 2 个不同版本的 webpack,你安装的那个导致它崩溃。

不要自己安装 webpack(从 package.json 中删除),它已经与 next.js 一起安装了

【讨论】:

  • 你能分享你的设置吗?以及如何在codeandbox或其他东西上重现该问题?
  • 如果你的设置很奇怪,而且你还需要外面的 webpack:只要你有相同的 webpack 版本,你就很好
  • 我正在使用create-react-app,我也有这个错误,我没有使用任何next.js
【解决方案2】:

在我的情况下,错误是我在 resolve.plugins 下放置了一个插件,而不是直接在 webpack 配置中的 plugins 中。解决方案来自:https://github.com/webpack/webpack/issues/8548#issuecomment-449829774

【讨论】:

  • 我正在使用create-react-app,我也有这个错误,我没有在任何地方使用任何resolve.plugins
【解决方案3】:

这是因为不同的 webpack。 尝试运行此命令。

npm install --save-dev webpack@4.44.0

【讨论】:

  • 是的,它奏效了。以前,由于指定的版本不正确,我曾经得到“点击未定义:错误”。谢谢大佬!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多