简体   繁体   English

找不到VueJS Grpc-Web模块

[英]VueJS Grpc-Web module not found

I've created a fresh VueJS application with TypeScript functionality. 我已经创建了具有TypeScript功能的全新VueJS应用程序。

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: 我得到以下文件:

在此处输入图片说明

When I move them to src/_protos in my VueJS project and try to import { PlatformClient } from '@/_protos/ServiceServiceClientPb'; 当我将它们移动到我的VueJS项目中的src/_protos并尝试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? 为什么是这样?

I believe this is resolved in https://github.com/grpc/grpc-web/issues/431 . 我相信可以在https://github.com/grpc/grpc-web/issues/431中解决。

In short, --js_out=import_style=typescript:. 简而言之,-- --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:. 您需要执行--js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:. --js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM