【问题标题】:VueJS Grpc-Web module not found未找到 VueJS Grpc-Web 模块
【发布时间】:2019-01-07 16:24:04
【问题描述】:

我创建了一个具有 TypeScript 功能的全新 VueJS 应用程序。

当我使用:

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

我得到以下文件:

当我在我的 VueJS 项目中将它们移至 src/_protos 并尝试移至 import { PlatformClient } from '@/_protos/ServiceServiceClientPb'; 时,出现以下错误:

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'

这是为什么?

【问题讨论】:

    标签: javascript typescript vue.js grpc grpc-web


    【解决方案1】:

    我相信这已在https://github.com/grpc/grpc-web/issues/431 中得到解决。

    简而言之,--js_out=import_style=typescript:. 不应该工作。你需要做--js_out=import_style=commonjs:. --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:.

    【讨论】:

    • 我确实找到了解决方案。
    猜你喜欢
    • 2017-11-24
    • 2017-12-17
    • 2021-08-31
    • 2018-12-20
    • 1970-01-01
    • 2018-04-15
    • 2020-09-28
    • 2019-09-11
    • 1970-01-01
    相关资源
    最近更新 更多