jQuery is not defined, Electron

246
January 08, 2020, at 4:50 PM

I am using microsoft adal for auth in my electron app. Nowhere in my app using jQuery, but when I try to logout, [I get this Error in my app console]

const redirectTo = `https://login.microsoftonline.com/${config.Adal.TenantID}/oauth2/v2.0/logout?post_logout_redirect_uri=${authContext.config.postLogoutRedirectUri}`;
const logout = () => {
    authContext.logOut();
    redirect(redirectTo, '/');    
};

authContext file

export const adalConfig = {
  clientId: config.Adal.ClientID,
  tenant: config.Adal.TenantID,
  cacheLocation: 'localStorage',
  redirectUri: config.Adal.RedirectURI,
  postLogoutRedirectUri: loginUrl
};
export const authContext = new AuthenticationContext(adalConfig);

The app gets stuck at 'Hang on a moment while we sign you out.'

Answer 1

If you tried to search the key words Uncaught ReferenceError: jQuery is not defined with Electron for your issue, you will get many solutions to fix it.

The frequently-used solutions are as below.

  1. If you load jQuery library like <script src="http://code.jquery.com/jquery-1.11.1.js"></script>, please use <script>window.$ = window.jQuery = require('jquery')</script> instead of it in Electron when you installed jQuery via npm install --save jquery.

  2. Change nodeIntegration: true to nodeIntegration: false to disable Node.js in the BrowserWindow instance.

  3. Replace the beginning content of jQuery as below as the static resource asset in Election with !function(a,b){b(a)}.

    // The beginning content need to be replaced
    !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}
    
Rent Charter Buses Company
READ ALSO
How can I make a loop command for my music bot? [closed]

How can I make a loop command for my music bot? [closed]

Want to improve this question? Add details and clarify the problem by editing this post

165
Best way to generate eforms lowcode

Best way to generate eforms lowcode

We currently build all our forms using ASPNET MVC with a MS SQL Server Backend

152
Dates changing between MongoDB and client?

Dates changing between MongoDB and client?

I am working on a Meteorjs application where dates are being stored in a Date MongoDB field on the server side, but when they are pulled up to the client side the immediately change

131
Node&#39;s spawn/exec not working when called from a scheduled Windows task

Node's spawn/exec not working when called from a scheduled Windows task

I'm facing a very odd issue where I have a Node script which invokes a process, it looks like this:

168