gpt4 book ai didi

getstream-io - ReferenceError : global is not defined with Stream and Angular 7. 1

转载 作者:行者123 更新时间:2023-12-03 09:54:47 28 4
gpt4 key购买 nike

我正在尝试将Stream与Angular 7结合使用,但是出现以下错误。

ReferenceError: global is not defined ReferenceError: global is not defined at Object../node_modules/faye/src/util/browser/event.js (event.js:45) at webpack_require (bootstrap:83) at Object../node_modules/faye/src/protocol/client.js (client.js:8) at webpack_require (bootstrap:83) at Object../node_modules/faye/src/faye_browser.js (faye_browser.js:9) at webpack_require (bootstrap:83) at Object../node_modules/getstream/lib/lib/client.js (client.js:25) at webpack_require (bootstrap:83) at Object../node_modules/getstream/lib/getstream.js (getstream.js:6) at webpack_require (bootstrap:83) at resolvePromise (zone.js:814) at resolvePromise (zone.js:771) at zone.js:873 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421) at Object.onInvokeTask (core.js:16147) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420) at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188) at drainMicroTaskQueue (zone.js:595)



我正在使用npm 4.1.0版中的“getstream”包。

这是一段代码以及我如何引用它。
import { Injectable } from '@angular/core';
import { Constants } from './../constants';
import * as stream from 'getstream';

@Injectable({
providedIn: 'root'
})
export class ActivityService {
userToken: string;
streamClient: stream.Client;

constructor(public azureService: AzureService) {
console.log("Activity Service");
}

async initializeClient() {
try {
await this.getUserToken();

if (this.userToken) {
this.streamClient = await stream.connect(Constants.streamKey, this.userToken, Constants.streamAppId);
}
}
catch (error) {
console.log('Error creating stream client - ', error);
throw error;
}
}

我尝试声明全局,但是我不确定还有什么尝试。在这种情况下,导入和使用Stream的正确方法是什么?

最佳答案

这看起来像一个Angular问题。他们确实为此提供了一些解决方法。
https://github.com/angular/angular-cli/issues/8160
https://github.com/angular/angular-cli/issues/9827#issuecomment-386154063

(window as any).global = window;

关于getstream-io - ReferenceError : global is not defined with Stream and Angular 7. 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54201934/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com