# Uncaught TypeError: elasticsearch.Client is not a constructor (elasticsearch.js)

**URL:** <https://discuss.elastic.co/t/uncaught-typeerror-elasticsearch-client-is-not-a-constructor-elasticsearch-js/137932>\
**Category:** Elasticsearch\
**Created:** [June 29, 2018, 10:14am UTC](https://discuss.elastic.co/t/uncaught-typeerror-elasticsearch-client-is-not-a-constructor-elasticsearch-js/137932 "2018-06-29T10:14:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rs123](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@rs123](https://discuss.elastic.co/u/rs123)\
**Post date:** [June 29, 2018, 10:14am UTC](https://discuss.elastic.co/t/uncaught-typeerror-elasticsearch-client-is-not-a-constructor-elasticsearch-js/137932/1 "2018-06-29T10:14:20Z")

</div>

Thirld line of the function show `Uncaught TypeError: elasticsearch.Client is not a constructor` I do not know why it is like this

```
function newAutocomplete(){
    var elasticsearch = 'elasticsearch';
    require([elasticsearch], function (elasticsearch) {});
    var esclient = new elasticsearch.Client({
      host: 'localhost:9200',
      log: 'trace'
    });
    esclient.search({
        index: 'user',
        body: {
            query:{
                match_all: {}
                }
            }
    }).then(function (resp) {
        var hits = resp.hits.hits;
    }, function (err) {
        console.trace(err.message);
    });
    $('#query_input').autocomplete({
        source: availableSuggs
    });
}

```

Any help would be really appreciated.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 27, 2018, 10:14am UTC](https://discuss.elastic.co/t/uncaught-typeerror-elasticsearch-client-is-not-a-constructor-elasticsearch-js/137932/2 "2018-07-27T10:14:26Z")

</div>

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