I am getting the error below in my nextjs application while building it. My nextjs application is configured with typescipt for building reasons though i am using js only.
Build error occurred:
TypeError: Cannot destructure property 'protocol' of 'window.location' as it is undefined.
at getLocationOrigin (/var/www/tradersnode/html/tradersnode/client/mpanel/node_modules/next/dist/next-server/lib/utils.js:3:162)
at Object.<anonymous> (/var/www/tradersnode/html/tradersnode/client/mpanel/node_modules/next/dist/next-server/lib/router/utils/parse-relative-url.js:1:206)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/var/www/tradersnode/html/tradersnode/client/mpanel/node_modules/next/dist/next-server/lib/router/router.js:1:558)
at Module._compile (internal/modules/cjs/loader.js:1156:30) {
type: 'TypeError'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This is my tsconfig.json file:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
]
}
I tried googling this bug but nothing relevant came back as a result.
I searched in my folder and in .next directory files i found this
`var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension`
I am not sure what i am doing wrong?
exportTrailingSlash
property set up... – Economically