ReferenceError: window is not defined

Hi all,

I installed this npm package: https://www.npmjs.com/package/datatables.net by doing

npm install datatables.net
meteor add jquery

And in my JS file (with the template helpers):

var $ = require( 'jquery' );
require( 'datatables.net' )( window, $ );

However, I’m getting this error:

ReferenceError: window is not defined

Any ideas on how to resolve this? Thanks.

Is that a client only code? Are you possibly seeing that error on your server console? In that case, make sure that code is only accessible within client code, or wrap it in an if (Meteor.isClient) {/* ... */} block.

1 Like

That worked, cheers @serkandurusoy

1 Like