Getting process not defined error when connecting angular 5 with ElasticSearch?

拜拜、爱过 提交于 2019-12-24 08:57:15

问题


It's my first time using angular with elastic and I am getting the above error on the line "this.client = new Client(//.."

exact error

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)

Here is the relevant code

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'
    });
  }

回答1:


Reinstalling the module solved the issue. Don't know what broke the installation in the first place.



来源:https://stackoverflow.com/questions/50364213/getting-process-not-defined-error-when-connecting-angular-5-with-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!