Angular 6 Auth0 - 全局未定义 [英] Angular 6 Auth0 - global not defined

查看:20
本文介绍了Angular 6 Auth0 - 全局未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将我的应用从 angular 5 升级到了 angular 6.我现在收到以下错误.

Uncaught ReferenceError: global is not defined在 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",

解决方案

这个角线:

<块引用>

在 Angular CLI 的第 6 版中,我们移除了 global 和其他节点内置.您可以阅读更多关于为什么进行此更改的信息在 #9827(评论)中.

如果您使用的库假定存在这些全局变量,则您可以尝试在 polyfills.ts 文件中手动填充它:

//给window添加global,赋值给window本身的值.(window as any).global = window;

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

Ive upgraded my app from angular 5 to angular 6. i get the following error now.

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",

解决方案

There was a similar issue in 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;

Adding the line should resolve your error.

这篇关于Angular 6 Auth0 - 全局未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆