question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VueJS + Grpc-Web "Module not found: Error: Can't resolve"

See original GitHub issue

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: screenshot 2019-01-06 at 16 37 46

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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
eberkundcommented, Jan 11, 2019

@stanley-cheung what do you mean with “You need to use the former.”?

The --js_out parameter doesn’t support typescript so what you actually want is:

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

See: https://github.com/grpc/grpc-web/issues/411

3reactions
stanley-cheungcommented, Jan 11, 2019

--js_out=import_style=typescript:.: this doesn’t work. The message part of the .proto generated by protoc --js_out= only supports import_style=commonjs or import_style=closure. You need to use the former.

--grpc-web_out=import_style=typescript will output a minimal set of typings for the messages in a .d.ts file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VueJS Grpc-Web module not found - Stack Overflow
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 ...
Read more >
Vuejs Grpc-Web Module Not Found - ADocLib
Fixed an issue where errors from grpc are thrown directly to user code. Added the missing type definitions for startAfter() and endBefore().
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
Read more >
Import not found in VueJS/TypeScript with gRPC-Web-Vue.js
VueJS and FontAwesome Import - Module not found: Error: Can't resolve '@fortawesome/fontawesome-svg-core' · VueJS 3 Composition API and TypeScript type ...
Read more >
@grpc/grpc-js - npm
Node 12 is recommended. The exact set of compatible Node versions can be found in the engines field of the package.json file. npm...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found