Angular 6 Auth0 - 全局未定义

Angular 6 Auth0 - global not defined

我已将我的应用程序从 angular 5 升级到 angular 6。我现在收到以下错误。

Uncaught ReferenceError: global is not defined
at Object../node_modules/auth0-lock/lib/utils/cdn_utils.js (cdn_utils.js:13)

"angular2-jwt": "^0.2.3", "auth0-js": "^9.5.1", "auth0-lock": "^11.6.1",

this angular thread 中存在类似问题:

On version 6 of Angular CLI we are removing the shim for global and other node built-ins. You can read more about why this change was made in #9827 (comment).

If you are using a library that assumes these globals are present, you can try manually shimming it inside your polyfills.ts file:

// Add global to window, assigning the value of window itself. (window as any).global = window;

添加该行应该可以解决您的错误。