[BUG] ReferenceError: window is not defined on datatables.net v1.13.6

[BUG] ReferenceError: window is not defined on datatables.net v1.13.6

ronig85588ronig85588 Posts: 1Questions: 0Answers: 0

Description of problem:
I created a Next.js 11 app with node.js v14. In the build process, I got ReferenceError. It seems the source code calls window when it's undefined. The problem likely occurs at line 57 of the source code.

Error messages shown:

Build error occurred
ReferenceError: window is not defined
    at .../node_modules/datatables.net/js/jquery.dataTables.js:57:24
    at Object.<anonymous> (.../node_modules/datatables.net/js/jquery.dataTables.js:65:1)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.8477 (.../.next/server/pages/administrator/list.js:607:18)
    at __webpack_require__ (.../.next/server/webpack-runtime.js:25:42) {
  type: 'ReferenceError'

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thank you. It looks like the logic for if (typeof window !== 'undefined') { on 41 is inverted. It should be returning a function if window is undefined, which would let you then execute that function, passing in the window object.

    What's a bit odd is that I've already fixed this. It looks like the dist repo sync hasn't completed for some reason. Looking into it...

    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Yup - the sync had fallen out of sync unfortunately. It is back to how it should be now. I'll tag up a release (1.13.7) on Monday.

    Allan

Sign In or Register to comment.