我正在开发我的Nuxt.js应用程序。数据库我选择了Milvus。我想做相似度搜索,但在浏览器控制台中遇到错误。
我有以下代码:
应用程序.vue
// Other code
<script setup lang="ts">
import { MilvusClient } from "@zilliz/milvus2-sdk-node";
// I also have other code not related to Milvus here, but I don't think it's relevant
(async () => {
const milvusClient = new MilvusClient({
address: "localhost:19530",
username: "",
password: "",
});
// Similarity search
const test = await milvusClient.search({
collection_name: "xxxxx", // My collection name here
vector: [ // My vector here ],
});
// Sort the results by score in descending order
const sortedResults = test.results.sort((a, b) => b.score - a.score);
// Display the descriptions with scores
sortedResults.forEach((result) => {
console.log(`[${result.score}]: ${result.description}`);
});
})();
</script>
包.json
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"devDependencies": {
"autoprefixer": "^10.4.16",
"nuxt": "^3.9.3",
"postcss": "^8.4.33",
"tailwindcss": "^3.4.1",
"vue": "^3.4.6",
"vue-router": "^4.2.5"
},
"dependencies": {
"@nuxt/ui": "^2.10.0",
"@zilliz/milvus2-sdk-node": "^2.3.5",
"nuxt-security": "^1.1.0"
}
}
正如您在上面看到的app.vue
,我使用Milvus 2 Node.js SDK,但我在浏览器控制台中收到以下错误:
TypeError: Class extends value undefined is not a constructor or null
at node_modules/@grpc/grpc-js/build/src/call.js (@zilliz_milvus2-sdk-node.js?v=bfe1cc22:10658:54)
at __require (chunk-PIXRU2QS.js?v=bfe1cc22:10:50)
at node_modules/@grpc/grpc-js/build/src/client.js (@zilliz_milvus2-sdk-node.js?v=bfe1cc22:11182:18)
at __require (chunk-PIXRU2QS.js?v=bfe1cc22:10:50)
at node_modules/@grpc/grpc-js/build/src/make-client.js (@zilliz_milvus2-sdk-node.js?v=bfe1cc22:11562:20)
at __require (chunk-PIXRU2QS.js?v=bfe1cc22:10:50)
at node_modules/@grpc/grpc-js/build/src/channelz.js (@zilliz_milvus2-sdk-node.js?v=bfe1cc22:11663:25)
at __require (chunk-PIXRU2QS.js?v=bfe1cc22:10:50)
at node_modules/@grpc/grpc-js/build/src/subchannel.js (@zilliz_milvus2-sdk-node.js?v=bfe1cc22:12227:22)
at __require (chunk-PIXRU2QS.js?v=bfe1cc22:10:50)
我一般性地搜索了这个错误,并在 StackOverflow 上找到了多个答案,说这可能是由循环依赖引起的。我曾经dpdm
发现潜在的循环依赖。
我运行了以下命令:
dpdm app.vue
但没有发现循环依赖:
✔ [0/0] Analyze done!
• Dependencies Tree
- 0) app.vue
• Circular Dependencies
✅ Congratulations, no circular dependency was found in your project.
• Warnings
我按照官方示例尝试了很长一段时间,但无法解决此错误。