I'm currently developing an application using Nuxt.js and have opted for Milvus as the database. I'm aiming to implement a similarity search feature, but I've hit a roadblock with an error popping up in the browser console.
The code snippet in question is as follows:
app.vue
// Other code
<script setup lang="ts">
import { MilvusClient } from "@zilliz/milvus2-sdk-node";
// Additional non-Milvus related code omitted for brevity
(async () => {
const milvusClient = new MilvusClient({
address: "localhost:19530",
username: "",
password: "",
});
// Perform Similarity Search
const test = await milvusClient.search({
collection_name: "xxxxx", // Placeholder for my collection name
vector: [ // Placeholder for my vector data ],
});
// Sort results by score in descending order
const sortedResults = test.results.sort((a, b) => b.score - a.score);
// Display descriptions along with scores
sortedResults.forEach((result) => {
console.log(`[${result.score}]: ${result.description}`);
});
})();
</script>
package.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"
}
}
Reviewing the provided app.vue
excerpt, it's evident that I'm utilizing the Milvus 2 Node.js SDK. However, the issue arises when I encounter the following error within the browser console:
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)
...
Various solutions on StackOverflow suggest that this error could be caused by circular dependencies. To investigate further, I utilized dpdm
to check for potential circular dependencies.
Running the command:
dpdm app.vue
Returned no circular dependencies:
✔ [0/0] Analyze done!
• Dependencies Tree
- 0) app.vue
• Circular Dependencies
✅ Congratulations, no circular dependency was found in your project.
• Warnings
Despite multiple attempts following official examples, resolving this error has proven to be challenging.