【发布时间】: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