相关文章推荐
爱逃课的李子  ·  使用 Public 文件夹 | ...·  17 小时前    · 
玉树临风的香菜  ·  Create React App - ...·  17 小时前    · 
朝气蓬勃的柿子  ·  luban-react-cli CDN ...·  17 小时前    · 
豁达的帽子  ·  Externals - Rspack·  17 小时前    · 
还单身的弓箭  ·  TypeError: Cannot ...·  2 小时前    · 
任性的钥匙扣  ·  Starwood Hotels and ...·  11 月前    · 
阳刚的路灯  ·  search results for ...·  11 月前    · 

Bug report

Describe the bug

I get the following error when trying to start my Next.js application in my production environment (AWS EBS):
TypeError: Cannot read property 'filter' of undefined at NextScript.getPolyfillScripts (/var/app/current/.next/server/static/8HSfigb_BmRkaQMwJTl6H/pages/_document.js:735:26) at NextScript.render (/var/app/current/.next/server/static/8HSfigb_BmRkaQMwJTl6H/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) a.b.render (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:476) a.b.read (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:44:18) renderToStaticMarkup (/var/app/current/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:54:462) renderDocument (/var/app/current/node_modules/next/dist/next-server/server/render.js:3:624) renderToHTML (/var/app/current/node_modules/next/dist/next-server/server/render.js:50:72) processTicksAndRejections (internal/process/task_queues.js:97:5)

The AWS EBS environment runs Node.js 12 on a 64bit Amazon Linux 2/5.2.0. I've deployed another app in a similar environment without any issues using v9.4.0 of Next.

To Reproduce

I build the app, zip it up, deploy it to AWS EBS and run npm start on port 8080.

Expected behavior

Expected behaviour is that the app starts without any internal server errors.

Screenshots

Stacktrace from my AWS environment:

System information

The AWS EBS environment runs Node.js 12 on a 64bit Amazon Linux 2/5.2.0. I use 9.4.0 of Next.

I changed the version of my production environment such that it is the same as my build environment. However, I experience some quite weird behaviour. When I start the app without specifying a port (i.e. port 3000), I don't get any error. However, when adding -p $PORT, I get the above error.
Any idea why this might happen?