I am creating react product using gatsby. I am using react-pdf library. It is givining follwoing error at build time. How can I solve it? I used gatsby 3.3.0 version. and using react-pdf 5.2.0
D:\Project\public\render-page.js:137661
window.requestAnimationFrame(resolve);
ReferenceError: window is not defined
at D:\Project\public\render-page.js:40343:3
at new Promise (<anonymous>)
at Object../node_modules/pdfjs-dist/lib/web/ui_utils.js (D:\Project\public\render-page.js:4034
2:26)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Object../node_modules/pdfjs-dist/lib/web/pdf_link_service.js (D:\Brisktech\Android\public\render-page
.js:39345:17)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/LinkService.js (D:\Project\public\render-page.js:4
4080:93)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/Document.js (D:\Project\public\render-page.js:4351
2:71)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../node_modules/react-pdf/dist/esm/entry.webpack.js (D:\Brisktech\Android\public\render-page.js
:46550:67)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Module../src/routes/default/index.js (D:\Project\public\render-page.js:7404:90)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
at Object../.cache/_this_is_virtual_fs_path_/$virtual/sync-requires.js (D:\Brisktech\Android\public\rend
er-page.js:6740:116)
at __webpack_require__ (D:\Project\public\render-page.js:48664:42)
D:\Project\public\render-page.js:40343
window.requestAnimationFrame(resolve);
^
failed Building static HTML for pages - 2.931s
ERROR #95313
Building static HTML failed
See our docs page for more info on this error: https://gatsby.dev/debug-html
10 |
11 | export default function _createClass(Constructor, protoProps, staticProps) {
> 12 | if (protoProps) _defineProperties(Constructor.prototype, protoProps);
| ^
13 | if (staticProps) _defineProperties(Constructor, staticProps);
14 | return Constructor;
15 | }
WebpackError: Call retries were exceeded
- createClass.js:12
[fitupme-app]/[@babel]/runtime/helpers/esm/createClass.js:12:1
error Command failed with exit code 1.
If I lower the version of react-pdf then It is working but giving warning. react-pdf: 4.2.0
ERROR
(node:6076) [DEP_WEBPACK_COMPILATION_CACHE] DeprecationWarning: Compilation.cache was removed in favor of
Compilation.getCache()
(Use `node --trace-deprecation ...` to show where the warning was created)
ERROR
(node:6076) [DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_HASH] DeprecationWarning: [hash] is now
[fullhash] (also consider using [chunkhash] or [contenthash], see documentation for details)
ERROR
(node:6076) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (in
dexing Array is deprecated)
Can Anyone solve this?