将Next.js部署到AWS Elastic Beanstalk时出错

问题描述

当我部署到AWS Elastic Beanstalk时,出现以下错误。有谁知道为什么会这样?

> [email protected] start /var/app/current
> next start -p $PORT

ready - started server on http://localhost:8081
TypeError: Cannot read property 'filter' of undefined
        at NextScript.getpolyfillScripts (/var/app/current/.next/server/static/8Nm58iB3JDC5SQahrWuy9/pages/_document.js:735:26)
        at NextScript.render (/var/app/current/.next/server/static/8Nm58iB3JDC5SQahrWuy9/pages/_document.js:836:75)
        at d (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:38:231)
        at $a (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:39:16)
        at a.b.render (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:476)
        at a.b.read (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:18)
        at renderToStaticmarkup (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:54:462)
        at renderDocument (/var/app/current/node_modules/next/dist/next-server/server/render.js:3:624)
        at renderToHTML (/var/app/current/node_modules/next/dist/next-server/server/render.js:50:72)
        at process._tickCallback (internal/process/next_tick.js:68:7)

解决方法

这里没有很多信息,但是当部署到ec2容器并升级到Next 9.5.1时,我遇到了这个确切的问题(以前是9.4.4)。