ReferenceError: window is not defined


#1

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.


#2

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.


#3

That worked, cheers @serkandurusoy