0

I want to be able to use jQuery in all my js files. I've downloaded the jQuery & jsdom modules through npm.

I've been incorporating my code into my app.js file. I've tried both:

global.$ = require('jquery')(global.window);

and

var varjsdom = require('jsdom').jsdom;
global.$ = require('jquery/dist/jquery')(jsdom().createWindow());

to no avail. How am I meant to get global permission to use jQuery?

Orange Receptacle
  • 1,173
  • 3
  • 19
  • 40
  • Possible duplicate of [Can I use jQuery with Node.js?](https://stackoverflow.com/questions/1801160/can-i-use-jquery-with-node-js) – baao Sep 10 '17 at 10:29

1 Answers1

0

you need to bind jQuery to any window object you create with jsDom otherwise your jQuery symbol is simply not bound to anything at all.

A Macdonald
  • 814
  • 1
  • 7
  • 10