Cannot consume elasticsearch client in angular application

Hi There I am using Angular10 and "@elastic/Elasticsearch": "^7.15.0", and getting the following dependency errors,


ERROR in ./node_modules/@elastic/elasticsearch/lib/Connection.js
    Module not found: Error: Can't resolve 'http' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'
    
    ERROR in ./node_modules/hpagent/index.js
    Module not found: Error: Can't resolve 'http' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/hpagent'
    
    ERROR in ./node_modules/@elastic/elasticsearch/lib/Connection.js
    Module not found: Error: Can't resolve 'https' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'
    
    ERROR in ./node_modules/hpagent/index.js
    Module not found: Error: Can't resolve 'https' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/hpagent'
    
    ERROR in ./node_modules/@elastic/elasticsearch/lib/Transport.js
    Module not found: Error: Can't resolve 'os' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'
    
    ERROR in ./node_modules/@elastic/elasticsearch/lib/Helpers.js
    Module not found: Error: Can't resolve 'stream' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'
    
    ERROR in ./node_modules/@elastic/elasticsearch/lib/Connection.js
    Module not found: Error: Can't resolve 'stream' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'
    
    ERROR in ./node_modules/@elastic/elasticsearch/lib/Transport.js
    Module not found: Error: Can't resolve 'zlib' in '/home/oaboamer/projects/pricetracer-ui-latest/pricetracer-ui/node_modules/@elastic/elasticsearch/lib'

This is how i import it

import {Client} from '@elastic/elasticsearch'

Create client

private client: Client = new Client({ node: '[https://node_url:9243](https://node_url:9243/)', auth: { username: 'test', password: '1234' } })

Any ideas ?

1 Like

I have the exact same problem, are there any ideas and / or solutions?

After researching on the internet, it tells me that I must use a webpac-custom-config, chosen that I managed to make but the problem is that it allows me other errors.

Suggestions ??

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.