Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: global is not defined in Angular 6 application #759

Closed
fetis opened this issue May 17, 2018 · 2 comments
Closed

ReferenceError: global is not defined in Angular 6 application #759

fetis opened this issue May 17, 2018 · 2 comments

Comments

@fetis
Copy link
Contributor

fetis commented May 17, 2018

Hello,

I'm facing this issue with fresh Angular 6 CLI project. The code to reproduce is very easy (config doesn't make sense here)

    this.auth = new WebAuth({
      clientID: 'xxx',
      domain: 'xxx',
      responseType: 'token id_token',
      audience: 'xxx',
      redirectUri: `${location.protocol}//${location.host}/callback`,
      scope: 'openid'
    });

    this.auth.authorize();

and it produces

ERROR ReferenceError: global is not defined
    at Object.getWindow (window.js:12)
    at Object.randomString (random.js:9)
    at TransactionManager.push../node_modules/auth0-js/src/web-auth/transaction-manager.js.TransactionManager.generateTransaction (transaction-manager.js:45)
    at TransactionManager.push../node_modules/auth0-js/src/web-auth/transaction-manager.js.TransactionManager.process (transaction-manager.js:20)
    at WebAuth.push../node_modules/auth0-js/src/web-auth/index.js.WebAuth.authorize (index.js:581)
    at new AuthComponent (auth.component.ts:25)
    at createClass (core.js:10146)
    at createDirectiveInstance (core.js:10033)
    at createViewNodes (core.js:11255)
    at callViewAction (core.js:11571)

This's because of

function getWindow() {
  return global.window;
}

in window.js

According angular/angular-cli#9827 (comment)
Angular team doesn't provide anymore any shimming for Node.js globals.

version: 9.5.1
Chrome 66 on MacOS, but I believe it's not browser specific.

@fetis
Copy link
Contributor Author

fetis commented May 17, 2018

The quick and hacky workaround would be

window.global = window

before any library usage

@luisrudge
Copy link
Contributor

duplicated #753 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants