问题描述:本地环境代码运行正常,docker打包错后代码运行报错。错误如下:
TypeError: Cannot read property 'filter' of undefined
at NextScript.getPolyfillScripts (/web/.next/server/static/XR8-mivDhVLY652oufpE9/pages/_document.js:767:26)12:02:43 0|index | at NextScript.render (/web/.next/server/static/XR8-mivDhVLY652oufpE9/pages/_document.js:866:41)
at d (/web/node_modules/_react-dom@16.13.1@react-dom/cjs/react-dom-server.node.production.min.js:38:231)
at $a (/web/node_modules/_react-dom@16.13.1@react-dom/cjs/react-dom-server.node.production.min.js:39:16)
at a.b.render (/web/node_modules/_react-dom@16.13.1@react-dom/cjs/react-dom-server.node.production.min.js:44:476)
at a.b.read (/web/node_modules/_react-dom@16.13.1@react-dom/cjs/react-dom-server.node.production.min.js:44:18)
at renderToStaticMarkup (/web/node_modules/_react-dom@16.13.1@react-dom/cjs/react-dom-server.node.production.min.js:54:462)
at renderDocument (/web/node_modules/_next@9.5.1@next/dist/next-server/server/render.js:3:594)
at renderToHTML (/web/node_modules/_next@9.5.1@next/dist/next-server/server/render.js:47:72)
at process._tickCallback (internal/process/next_tick.js:68:7)
原因分析:可能引入的包版本冲突导致。
解决办法:把next(9.2.2)的包版本降级问题得到解决