After upgrading from nextJS version 9.x.x to 12.x.x, I encountered the following error. Any assistance would be greatly appreciated.
TypeError: file.endsWith is not a function
at eval (webpack-internal:///./node_modules/next/dist/pages/_document.js:171:60)
at Array.filter (<anonymous>)
at getScripts (webpack-internal:///./node_modules/next/dist/pages/_document.js:171:40)
at Head.getScripts (webpack-internal:///./node_modules/next/dist/pages/_document.js:367:12)
at getDynamicScriptContent (webpack-internal:///./node_modules/next/dist/pages/_document.js:553:297)
at eval (webpack-internal:///./node_modules/next/dist/pages/_document.js:557:142)
at useMaybeDeferContent (/Users/majid.hussain/workspace/hub-next/node_modules/next/dist/server/render.js:1251:9)
at DeferrableHead (webpack-internal:///./node_modules/next/dist/pages/_document.js:556:28)
at processChild (/Users/majid.hussain/workspace/hub-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3353:14)
at resolve (/Users/majid.hussain/workspace/hub-next/node_modules/react-dom/cjs/react-dom-server.node.development.js:3270:5)
This is the transpiled code where the error occurs.
https://i.sstatic.net/emB0V.png
Furthermore, here is the output of the console.log I implemented to check for any potential null values:
{
sharedFiles: [
'static/chunks/fallback/webpack.js',
'static/chunks/fallback/main.js',
'static/chunks/fallback/pages/_app.js'
],
pageFiles: [
'static/chunks/fallback/webpack.js',
'static/chunks/fallback/main.js',
'static/chunks/fallback/pages/_error.js'
],
allFiles: [
'static/chunks/fallback/webpack.js',
'static/chunks/fallback/main.js',
'static/chunks/fallback/pages/_app.js',
'static/chunks/fallback/pages/_error.js'
]
}