Search code examples
javascripttypescriptvue.jsgrpcgrpc-web

VueJS Grpc-Web module not found


I've created a fresh VueJS application with TypeScript functionality.

When I generate using:

protoc -I=. service.proto --js_out=import_style=typescript:. --grpc web_out=import_style=typescript,mode=grpcwebtext:.

I get the following files:

enter image description here

When I move them to src/_protos in my VueJS project and try to import { PlatformClient } from '@/_protos/ServiceServiceClientPb'; it gives me the following error:

Failed to compile.
./src/_protos/ServiceServiceClientPb.ts
Module not found: Error: Can't resolve './service_pb' in '/Users/theobouwman/dev/woodyshousing/woody_web/src/_protos'

Why is this?


Solution

  • I believe this is resolved in https://github.com/grpc/grpc-web/issues/431.

    In short, --js_out=import_style=typescript:. is not supposed to work. You need to do --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:.