Looking for help with integrating a typescript Vue.js component that needs to make a grpc call.
The proto file can be found here: https://github.com/floydjones1/ts-node-grpc/blob/main/proto/random.proto
Here is the component.vue code snippet:
<script setup lang="ts">
import path from 'path'
import { ref } from "vue";
import * as grpcJs from "@grpc/grpc-js";
import * as protoLoader from "@grpc/proto-loader";
import type { ProtoGrpcType } from "./proto/random";
const PROTO_FILE = './proto/random.proto'
const packageDefinition = protoLoader.loadSync(path.resolve(__dirname, PROTO_FILE))
const grpcObject = (grpcJs.loadPackageDefinition(packageDefinition) as unknown) as ProtoGrpcType
</script>
When running the page with this component, an error occurs:
ReferenceError: process is not defined
node_modules grpc/grpc-js/build/src/logging.js@http://localhost:5173/node_modules/.vite/deps/@grpc_grpc-js.js?v=ed969e6f:79
__require http://localhost:5173/node_modules/.vite/deps/chunk-RSJERJUL.js?v=ed969e6f:3
node_modules grpc/grpc-js/build/src/metadata.js@http://localhost:5173/node_modules/.vite/deps/@grpc_grpc-js.js?v=ed969e6f:185
__require http://localhost:5173/node_modules/.vite/deps/chunk-RSJERJUL.js?v=ed969e6f:3
node_modules grpc/grpc-js/build/src/call-credentials.js@http://localhost:5173/node_modules/.vite/deps/@grpc_grpc-js.js?v=ed969e6f:410
__require http://localhost:5173/node_modules/.vite/deps/chunk-RSJERJUL.js?v=ed969e6f:3
node_modules grpc/grpc-js/build/src/index.js@http://localhost:5173/node_modules/.vite/deps/@grpc_grpc-js.js?v=ed969e6f:9983
__require http://localhost:5173/node_modules/.vite/deps/chunk-RSJERJUL.js?v=ed969e6f:3
<anonymous> http://localhost:5173/node_modules/.vite/deps/@grpc_grpc-js.js?v=ed969e6f:10144
The grpc call works outside of Vue.js. Any suggestions on how to resolve this issue?