【问题标题】:Next.js 11 TypeError: Cannot read property 'forEach' of undefinedNext.js 11 TypeError:无法读取未定义的属性“forEach”
【发布时间】:2021-08-12 09:30:14
【问题描述】:

将Next.js从10更新到11后,运行npm run build时出现如下错误:

Module parse failed: Cannot read property 'forEach' of undefined
File was processed with these loaders: * ./node_modules/next/dist/build/babel/loader/index.js
You may need an additional loader to handle the result of these loaders.
TypeError: Cannot read property 'forEach' of undefined>

Build error occurredError: > Build failed because of webpack errors

这似乎是使用扩展运算符触发的问题,因为如果我删除了扩展运算符的所有使用,则构建成功。

我发现了这些类似的问题,但没有一个是 Next.js 11 特有的:

【问题讨论】:

    标签: javascript webpack next.js babeljs babel-loader


    【解决方案1】:

    在这里回答我自己的问题,希望可以为某人节省几个小时的调试时间:

    我可以通过将 Next.js 从 11.0.1 更新为 11.1.0 来解决此问题。

    但是,即使这解决了问题,我仍然不知道根本原因是什么,也没有在 changelog 中找到任何相关的修复程序,因此感谢您的回答。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-19
      • 1970-01-01
      • 1970-01-01
      • 2021-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多