使用 ElasticSearch 连接 angular 5 时出现进程未定义错误?
Getting process not defined error when connecting angular 5 with ElasticSearch?
这是我第一次使用 angular 和 elastic,我在 "this.client = new Client(//.."
行收到上述错误
确切错误
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 (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'
});
}
重新安装模块解决了问题。不知道是什么首先破坏了安装。
我发现几个线程和下面的命令对我有用。 reference
npm i -S process,
然后将以下 2 行添加到 polyfill.ts 文件。
import * as process from 'process';
window['process'] = process;
这是我第一次使用 angular 和 elastic,我在 "this.client = new Client(//.."
行收到上述错误确切错误
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 (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'
});
}
重新安装模块解决了问题。不知道是什么首先破坏了安装。
我发现几个线程和下面的命令对我有用。 reference
npm i -S process,
然后将以下 2 行添加到 polyfill.ts 文件。
import * as process from 'process';
window['process'] = process;