node.jselasticsearchaws-elasticsearch

TypeError: trying to use aws-elasticsearch-connector


I'm attempting to update a legacy elastic-search node app, using the the package aws-elasticsearch-connector

and for some reason I'm unable to get it to work at all, even the simplest provided example...

I installed the packages, exactly as shown...

> npm install --save aws-elasticsearch-connector @elastic/elasticsearch aws-sdk

This is the sample code...

const { Client } = require('@elastic/elasticsearch')
const AWS = require('aws-sdk')
const createAwsElasticsearchConnector = require('aws-elasticsearch-connector')

// (Optional) load profile credentials from file
AWS.config.update({
  profile: 'myawsprofile'
})

const client = new Client({
  ...createAwsElasticsearchConnector(AWS.config),
  node: 'https://my-elasticsearch-cluster.us-east-1.es.amazonaws.com'
})

When I attempt to run it with this...

> node .\index.js

I get this error...

class AmazonConnection extends Connection {

TypeError: Class extends value undefined is not a constructor or null

I have no idea how I'm supposed to fix this, since the error seems to be in the module itself, not my sample code.

Most of the examples of this error that I've seen, suggest that it's related to circular references, but that doesn't seem to be of any help to me.

I'm using node v16.14.0

This is my package.json...

{
  "name": "test_es",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@elastic/elasticsearch": "^8.0.0",
    "aws-elasticsearch-connector": "^9.0.3",
    "aws-sdk": "^2.1087.0"
  }
}

I'm probably doing something wrong, or the package author may be assuming some additional knowledge that I just don't have.

Any suggestions would be greatly appreciated.


Solution

  • It seems version 8 of @elastic/elasticsearch is not compatible with aws-elasticsearch-connector.

    Changing to version 7.17.0 seems to resolve this particular error.