Javascript 获取错误无法分解属性';协议';属于';窗口位置';因为它在构建nextjs应用程序时未定义

Javascript 获取错误无法分解属性';协议';属于';窗口位置';因为它在构建nextjs应用程序时未定义,javascript,typescript,build,next.js,window.location,Javascript,Typescript,Build,Next.js,Window.location,我在构建nextjs应用程序时遇到以下错误。我的nextjs应用程序配置为typescipt是出于构建原因,尽管我只使用js Build error occurred: TypeError: Cannot destructure property 'protocol' of 'window.location' as it is undefined. at getLocationOrigin (/var/www/tradersnode/html/tradersnode/client/mp

我在构建nextjs应用程序时遇到以下错误。我的nextjs应用程序配置为typescipt是出于构建原因,尽管我只使用js

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.
我试着用谷歌搜索这个bug,但结果没有相关的结果

我在我的文件夹和.next目录文件中搜索到了这个

 `var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension`

我不确定我做错了什么?

我在运行
next dev
时出错

原因是我的
next.config.js
中有
exportTrailingSlash:true

例如,如果我打开了
/about
,它会产生错误,但是如果我打开了
/about/
,一切都会正常工作。

但是OP没有设置
exportTrailingSlash
属性……这并不能回答这个问题。一旦你有足够的钱,你将能够;相反-
 `var protocol = window.location.protocol; // Don't warn in exotic cases like chrome-extension`