-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
AgoraRTC SDK version
4.20.0
Fail Rate
100%
Link to minimal reproduction
https://github.com/BikeF/test-agora-rtc-sdk-ng.git
Steps to reproduce
- npm install
- npm run dev
- open the page, You will find that the console reports an error:
⨯ ReferenceError: window is not defined
at __webpack_require__ (C:\Users\fanfa\Documents\test-agora-rtc-sdk-ng\.next\server\webpack-runtime.js:33:43)
at eval (./src/app/page.tsx:8:74)
at (ssr)/./src/app/page.tsx (C:\Users\fanfa\Documents\test-agora-rtc-sdk-ng\.next\server\app\page.js:129:1)
at Object.__webpack_require__ [as require] (C:\Users\fanfa\Documents\test-agora-rtc-sdk-ng\.next\server\webpack-runtime.js:33:43)
digest: "942138213"
What is expected?
the module file is AgoraRTC_N-production.js,simple code:
!function (e, t) {
if ("object" === typeof exports && "undefined" !== typeof module) {
module.exports = t();
} else if ("function" === typeof define && define.amd) {
define(t);
} else {
e = "undefined" !== typeof globalThis ? globalThis : e || self;
e.AgoraRTC = t();
}
}(this, (function () {
nextjs will exeute t() // from module.exports = t();
in server,so window is not undefined
"agora-rtm" has the same problem.
What is actually happening?
npm run dev will report an error, but it will not affect the use.
npm run build will report an error and cause packaging failure.
I should be able to avoid reporting errors by importing synchronously, but I don't want to do so.
System Info
nextjs14
Any additional comments?
No response