Encountered a Milvus 2 Node.js SDK issue: "Error: TypeError: Class extends value undefined is not a constructor or null"

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.

Answer №1

Unfortunately, the library @grpc/grpc-js is not compatible with browsers and can only be used with Node.js. It seems that this library is being included as a transitive dependency of the Milvus 2 Node.js SDK, which explicitly mentions in its README that it relies on Node.js for functionality.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Variables in TypeScript to Enhance String Literal Types

Here are my codes: export const LOAD_USERS = 'LOAD_USERS'; export const CREATE_USER = 'CREATE_USER'; export interface ACTION { type: string, payload: any } I am trying to limit the possible values for ACTION.type to either 'L ...

Using Angular to Bind Checkbox Value in Typescript

I have a challenge of creating a quiz where a card is displayed with 4 questions structured like this: <div class="col-md-6"> <div class="option" id="Answer1"> <label class="Answer1"> <input value= "Answer1" type="checkbox ...

Next.js's router.push method directs the user to the specified URL and refreshes the page

I am facing an issue with my page structure: pages [re] login [slug.tsx] When I navigate from http://localhost:3000/in/login/data1 to http://localhost:3000/in/login/data2 using router.push on button click, the route is updated but th ...

Resolve functionality in UI Router fails to function properly when utilizing component-based states

Issue: In a project I am currently involved in, there is a component that is utilized in two different scenarios. One instance involves calling it from the Material Design system's bottomSheet, while the other requires direct usage through the ui-ro ...

Finding the hidden treasure within a nested array and transforming a boolean gem into a dazzling string - the ultimate quest!

How do I convert the values in the "active" field to "Yes" if true and "No" if false? [ { "id":81, "time":"2022-01-01 19:30:00", "subList":[ { "active":false, "success":null } ] }, { "id":89, "time":"2022-01-01 21:00:15", "subList":[ { "active":true, "suc ...

Finding the solution to the perplexing issue with Generic in TypeScript

I recently encountered a TypeScript function that utilizes Generics. function task<T>(builder: (props: { propsA: number }, option: T) => void) { return { run: (option: T) => {}, } } However, when I actually use this function, the Gener ...

ngRepeat momentarily displays duplicate items in the list

There is a modal that appears when a button is clicked. Inside the modal, there is a list of items that is populated by data from a GET request response stored in the controller. The issue arises when the modal is opened multiple times, causing the list t ...

An error was detected in the card-module.d.ts file located in the node_modules folder within the @angular/material/card/typings directory

Currently, I am working on an angular project using Visual Studio Code as my text editor. When attempting to open the project with 'npm start', an error occurred. The specific error message is: ERROR in node_modules/@angular/material/card/typing ...

I am in the process of creating a Vue.js/Nuxt application and I am looking to develop a similar app with a different style. Both versions will be

I am facing a situation with my VueJs/nuxt app. The challenge is to deploy the same application for a different client on the same server but with unique CSS/Images and under a different URL. The current process involves pulling the branch on the Linux s ...

Evolving fashion trends

I'm looking to dynamically change the style of my HTML element based on screen size, similar to this example: <p [ngStyle]="{'color': isMobile() ? 'red' : 'blue'}">Lorem Ipsum</p> The code above triggers a m ...

What are the steps for running a separate version of the selected_process and outdated_process?

Here's the code I've written to combine two history components into one. I'm using an if-else loop to achieve this, and it seems to be working fine. However, both icons end up showing all outdated processes. useEffect(() => { getVers ...

Enriching SpriteWithDynamicBody with Phaser3 and Typescript

Is there a way to create a custom class hero that extends from SpriteWithDynamicBody? I'm unable to do so because SpriteWithDynamicBody is only defined as a type, and we can't extend from a type in Typescript. I can only extend from Sprite, but ...

typescript error caused by NaN

Apologies for the repetitive question, but I am really struggling to find a solution. I am facing an issue with this calculation. The parameters a to g represent the values of my input from the HTML. I need to use these values to calculate a sum. When I tr ...

What steps should I take to retrieve my information from a typescript callback function?

While I am familiar with using callbacks in JavaScript, I have recently started learning Angular and TypeScript. I am facing an issue with getting my data from a service back to where I need it after executing the callback function. The callback itself i ...

Using TypeScript to Return a Derived Class as a Method's Return Type

I'm currently facing a challenge with an abstract class in typescript that includes a method to provide a callback for later use. The issue lies in the return type of the method, as it is set to the class itself, preventing me from using fluent style ...

Evaluate TypeScript method against the interface, for example T['methodName']

Suppose we have an interface: class A { method(x:number) : string } And a function: const b = (x: string) : number; Our goal is to test the function against the interface. Here is one way to achieve this: type InterfaceKey = { method: any }; ...

Retrieving information from a JSON API using Angular with Typescript

Currently, I am dealing with an API JSON to fetch a list of countries, followed by a list of states, and then cities within that state and country. The challenge lies in the second API call that I make. In the beginning, I load a list of continents and the ...

Reading files from multiple sources using Angular's FormArray

I am facing an issue with uploading multiple images from different inputs. I have a form set up with a formArray to add a new input each time the "Add file" button is clicked. this.designForm = this.fb.group({ newFiles: this.fb.array([ this.f ...

Ways to utilize the output from an axios request in constructing the input for another request

Currently, my asyncData function is set up like this and successfully populating data for events and booking using axios requests: async asyncData({ params, app }) { const events = await app.$api.event.index(app.i18n.locale) const booking = await app.$ ...

Limiting @Input Value to a Certain Number Range using Angular

I need to include an InputSignal in my Angular component that only accepts arrays of numbers. Each number in the array should fall between 0.01 and 10, and cannot have more than 2 decimal places. It is important to enforce these restrictions to ensure tha ...