Currently, I am working on creating an application with nextJS and incorporating a package that utilizes Webfontloader
internally. After installing the library, my application encountered an error preventing it from running successfully. It seems like the error occurred when nextjs attempted to compile an app referencing window
on the server-side. Any assistance in resolving this issue would be greatly appreciated.
ReferenceError: window is not defined
at eval (webpack-internal:///./src/[REDACTED]/node_modules/webfontloader/webfontloader.js:1:711)
at eval (webpack-internal:///./src/[REDACTED]/node_modules/webfontloader/webfontloader.js:18:103)
at Object../src/[REDACTED]/node_modules/webfontloader/webfontloader.js (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/pages/index.js:2941:1)
at __webpack_require__ (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/webpack-runtime.js:33:43)
at eval (webpack-internal:///./src/[REDACTED]/lib/Button/ButtonGroup.js:39:22)
at Object../src/[REDACTED]/lib/Button/ButtonGroup.js (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/pages/index.js:982:1)
at __webpack_require__ (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/webpack-runtime.js:33:43)
at eval (webpack-internal:///./src/[REDACTED]/lib/Button/index.js:16:20)
at Object../src/[REDACTED]/lib/Button/index.js (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/pages/index.js:1015:1)
at __webpack_require__ (/Users/MyUser/codebase/codepan/[REDACTED]/.next/server/webpack-runtime.js:33:43)