Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hit <foo>_pb.js does not provide an export named '<foo>' syntax error #143

Open
khteh opened this issue Jul 11, 2024 · 0 comments
Open

Hit <foo>_pb.js does not provide an export named '<foo>' syntax error #143

khteh opened this issue Jul 11, 2024 · 0 comments

Comments

@khteh
Copy link

khteh commented Jul 11, 2024

I generate proto js files with:

npx grpc_tools_node_protoc --js_out=import_style=commonjs,binary:./grpc/client --grpc_out=grpc_js:./grpc/client --plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin` -I ./grpc/proto ./grpc/proto/*.proto && npx protoc --plugin=protoc-gen-ts=`which protoc-gen-ts` --ts_out=grpc_js:./grpc/client -I ./grpc/proto ./grpc/proto/*.proto

These are the generated artefacts:
image

I don't see any error when building the typescript project. However, when I run I hit this error:

$ export PORT=4433&&n run start

> [email protected] start
> export NODE_ENV=development&& node --experimental-specifier-resolution=node build/src/webapi/server.js

file:///usr/src/Node.JSRestAPI/build/src/webapi/Services/SchoolService.js:5
import { CommonStudentsResponse as grpcCommonStudentsResponse, } from "../grpc/client/school_pb.js";
         ^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '../grpc/client/school_pb.js' does not provide an export named 'CommonStudentsResponse'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:171:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:254:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:475:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:109:5)

Node.js v22.2.0

I see the symbol being defined in the file in question:
image
What do I miss?

Environment

  • OS name, version and architecture: [e.g. Linux Ubuntu 18.04 amd64] Ubuntu 24.04
  • Node version [e.g. 8.10.0] 22.4.1
  • Node installation method [e.g. nvm] apt
  • If applicable, compiler version [e.g. clang 3.8.0-2ubuntu4] g++ 13.2.0
  • Package name and version [e.g. [email protected]]:
    "grpc_tools_node_protoc_ts": "^5.3.3",
    "@grpc/grpc-js": "^1.10.10",
    "@grpc/proto-loader": "^0.7.13",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant