将Angle 5与ElasticSearch连接时获取流程未定义错误? [英] Getting process not defined error when connecting angular 5 with ElasticSearch?
问题描述
这是我第一次使用带有弹性的角度,并且在 this.client = new Client(// ..行上遇到了以上错误。
It's my first time using angular with elastic and I am getting the above error on the line "this.client = new Client(//.."
exact错误
ReferenceError:在Log.push ../ node_modules / elasticsearch / src / lib / log中未定义进程
。 js.Log.addOutput(log.js:213)
在新Log(log.js:51)
在新Transport(transport.js:19)
在新EsApiClient(客户端。 js:58)新客户端上的
(client.js:101)ElasticsearchService.push ../ src / app / elasticsearch.service.ts.ElasticsearchService.connect(elasticsearch.service.ts:23上的
)
在新的ElasticsearchService(elasticsearch.service.ts:18)
在_createClass(core.js:9260)
在_createProviderInstance $ 1(core.js:9234)
在resolveNgModuleDep (core.js:9200)
ReferenceError: process is not defined at Log.push../node_modules/elasticsearch/src/lib/log.js.Log.addOutput (log.js:213) at new Log (log.js:51) at new Transport (transport.js:19) at new EsApiClient (client.js:58) at new Client (client.js:101) at ElasticsearchService.push../src/app/elasticsearch.service.ts.ElasticsearchService.connect (elasticsearch.service.ts:23) at new ElasticsearchService (elasticsearch.service.ts:18) at _createClass (core.js:9260) at _createProviderInstance$1 (core.js:9234) at resolveNgModuleDep (core.js:9200)
这是相关代码
import { Client } from 'elasticsearch';
import { Injectable } from '@angular/core';
@Injectable()
export class ElasticsearchService {
private client: Client;
queryalldocs = {
'query': {
'match_all': {}
}
};
constructor() {
if (!this.client) {
this.connect();
}
}
private connect() {
this.client = new Client({
host: 'http://localhost:9200',
log: 'trace'
});
}
推荐答案
重新安装模块即可解决此问题。首先不知道是什么原因导致安装失败。
Reinstalling the module solved the issue. Don't know what broke the installation in the first place.
这篇关于将Angle 5与ElasticSearch连接时获取流程未定义错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!