0

I am trying to use Electron 1.4.4 to create a test client for testing OpenID Connect on our web site and having an issue with jQuery not working correctly.

I open our site using a new BrowserWindow from the main process and see the page. When I look in DevTools console I see a lot of 'jQuery is not defined' errors. When I load the same page in Chrome, I do not see the errors.

Did a little digging with the help of a UI co-worker and he found a couple of differences. In Chrome 50 jQuery is defined on the window object (window.jQuery is a function) and module is not defined (module is undefined). In Chromium 53 jQuery is not defined (jQuery and window.jQuery are undefined) and module is defined (module is an object).

Not sure if this is relevant but the page is generated by Drupal which is managed by a different team.

Thanks, Wes.

Wes
  • 847
  • 2
  • 10
  • 22
  • Adding `nodeIntegration: false` to the `webPreferences` disables CommonJS and allow JQuery to install correctly but not sure how I can access the DOM in the renderer process from the main process. – Wes Nov 03 '16 at 12:52

1 Answers1

0

This looks like a duplicate of this post.

The below solution from the post would allow you to keep node integration while still having access to jQuery.

window.$ = window.jQuery = require('./path/to/jquery');

If you "npm install --save jquery", then you don't need to specify the path to jquery as "require('jquery')" will resolve.

The linked to post has a few other ways to work around this. When I first ran into this issue, it about drove me mad.

Community
  • 1
  • 1
Joshua Benuck
  • 91
  • 1
  • 5