Vite and those npm packages are problematic. They can work, but there are several workarounds to deal with. It is better to use axios instead, unless you really need gRPC
An update on this. All Dgraph clients are designed to run on the server. That means Dgraph.JS should be running on Node.js and not in a front-end application. Why is that? It’s simple because it is not safe to provide direct access to the database through the front-end. In theory, you should only do this in very specific cases that don’t involve end users, as it poses a serious security risk.
You should create an API or use GraphQL to handle the front-end. For those who are not using GraphQL, it is highly recommended to create your own API that sits between the backend and frontend. Avoid exposing Dgraph to the front-end at all costs.