类型错误:尝试使用 aws-elasticsearch-connector

发布于 2025-01-11 17:37:41 字数 1490 浏览 0 评论 0原文

我正在尝试使用 aws-elasticsearch-connector 包更新遗留的弹性搜索节点应用程序,

由于某种原因,我根本无法让它工作,即使是提供的最简单的示例......

我安装了包,完全如图所示...

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

这是示例代码...

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

当我尝试用这个运行它时...

> node .\index.js

我收到此错误...

class AmazonConnection extends Connection {

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

我不知道应该如何解决这个问题,因为错误似乎在模块本身中,而不是我的示例代码中。

我见过的大多数此错误的示例都表明它与循环引用有关,但这似乎对我没有任何帮助。

我正在使用节点 v16.14.0

这是我的 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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

橘寄 2025-01-18 17:37:41

@elastic/elasticsearch 的版本 8 似乎与 aws-elasticsearch-connector 不兼容。

更改为版本 7.17.0 似乎可以解决此特定错误。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文