当我在任何文件中时,我的 Next.js/React/Node 应用程序崩溃import Chart from "react-apexcharts"
。尝试访问应用程序会导致以下错误:(Server Error
ReferenceError: window is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
请参阅下面的调用堆栈)。
无论导入的内容<Chart/>
是在页面中呈现还是未使用,都会发生这种情况。有趣的是,如果我保存文件并启动 Next.js 快速刷新,我的应用程序就会开始正常工作(有时)。但是,当我刚刚启动应用程序并尝试访问它时,或者当我使用f5手动刷新时,会发生上述错误。基本上,它仅在 Next.js 快速刷新后才起作用(有时,大概是随机的,它在这种情况下也不起作用,抛出与以前相同的错误)。
Node.js (14.16.0)、React (17.0.2)、Express (4.17.1)、Next.js (10.2.0)、react-apexcharts
(1.3.9)、apexcharts
(3.26.3)、Edge 浏览器、Win10。
Next.js 服务器与 Express 服务器集成在一起。
ReferenceError: window is not defined
at Object.<anonymous> (C:\Users\georg\Documents\development\web\projects\Angelina-Website\node_modules\apexcharts\dist\apexcharts.common.js:6:345884)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at …
Run Code Online (Sandbox Code Playgroud)