简体   繁体   English

Angular应用程序转移到版本6错误:“未定义全局”

[英]Angular app transfer to version 6 error: 'Global is not defined'

So I was hoping to transfer my MEAN stack app to Angular 6 and I set everything up and when I tried to fire up the app I got the following error in the console: 所以我希望将我的MEAN堆栈应用程序转移到Angular 6,并进行所有设置,而当我尝试启动该应用程序时,控制台中出现以下错误:

在此处输入图片说明

Does anyone have any idea what causes this? 有谁知道这是什么原因? I went to look for it in the specified package and found the following: 我去指定的包中查找它,发现以下内容:

在此处输入图片说明

In the pre-6 versions of Angular the global variable and couple of other nodejs-specific variables like process etc. were faked by Angular itself in order to work properly. 在Angular的6之前的版本中,Angular本身伪造了global变量和其他几个nodejs特定变量,例如process等,以使其正常工作。

So, the only way to make this working again is: 因此,再次使它工作的唯一方法是:

(window as any).global = window;

in your main.ts / polyfills.ts or (I did not test this one, but looks also might be working) main.ts / polyfills.ts或(我没有测试这一个,但看起来也可能是工作)

import 'intl';

in the polyfills.ts polyfills.ts

See https://github.com/angular/angular-cli/issues/9920 for more info. 有关更多信息,请参见https://github.com/angular/angular-cli/issues/9920

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM