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

Nodejs Getting started guide is not working #1177

Closed
holomekc opened this issue Aug 4, 2024 · 7 comments
Closed

Nodejs Getting started guide is not working #1177

holomekc opened this issue Aug 4, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@holomekc
Copy link

holomekc commented Aug 4, 2024

Describe the bug

Following this guide: https://connectrpc.com/docs/node/getting-started
But it is not working

To Reproduce

Project Setup
https://connectrpc.com/docs/node/getting-started#project-setup
Fails with:

mkdir connect-example
cd connect-example
npm init -y
npm install typescript tsx
npx tsc --init
npm install @bufbuild/buf @bufbuild/protoc-gen-es @bufbuild/protobuf @connectrpc/protoc-gen-connect-es @connectrpc/connect
npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: [email protected]
npm error Found: @bufbuild/[email protected]
npm error node_modules/@bufbuild/protobuf
npm error   @bufbuild/protobuf@"*" from the root project
npm error   @bufbuild/protobuf@"^2.0.0" from @bufbuild/[email protected]
npm error   node_modules/@bufbuild/protoc-gen-es
npm error     @bufbuild/protoc-gen-es@"*" from the root project
npm error
npm error Could not resolve dependency:
npm error @connectrpc/connect@"*" from the root project
npm error
npm error Conflicting peer dependency: @bufbuild/[email protected]
npm error node_modules/@bufbuild/protobuf
npm error   peer @bufbuild/protobuf@"^1.4.2" from @connectrpc/[email protected]
npm error   node_modules/@connectrpc/connect
npm error     @connectrpc/connect@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /Users/something/.npm/_logs/2024-08-04T10_59_49_443Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/something/.npm/_logs/2024-08-04T10_59_49_443Z-debug-0.log

using --force to the install command kind of works.

Generate Code
https://connectrpc.com/docs/node/getting-started#generate-code

proto/eliza.proto:3:1:Files with package "connectrpc.eliza.v1" must be within a directory "connectrpc/eliza/v1" relative to root but were in directory ".".

Complains that package and dir structure does not match up. It still generates code though.

Start a server
https://connectrpc.com/docs/node/getting-started#start-a-server

npm install fastify @connectrpc/connect-node @connectrpc/connect-fastify
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: @bufbuild/[email protected]
npm error node_modules/@bufbuild/protobuf
npm error   @bufbuild/protobuf@"^2.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @bufbuild/protobuf@"^1.4.2" from @connectrpc/[email protected]
npm error node_modules/@connectrpc/connect-node
npm error   @connectrpc/connect-node@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /Users/something/.npm/_logs/2024-08-04T11_06_58_884Z-eresolve-report.txt
npm error A complete log of this run can be found in: /Users/something/.npm/_logs/2024-08-04T11_06_58_884Z-debug-0.log

Again --force kind of helps

But then actually starting the server fails:

npx tsx server.ts
/Users/something/dev/git/github/test2/connect-example/node_modules/@connectrpc/connect/dist/cjs/protocol-grpc/gen/status_pb.js:74
class Status extends protobuf_1.Message {
                                ^

TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (/Users/something/dev/git/github/test2/connect-example/node_modules/@connectrpc/connect/dist/cjs/protocol-grpc/gen/status_pb.js:74:33)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object.transformer (/Users/something/dev/git/github/test2/connect-example/node_modules/tsx/dist/register-C1urN2EO.cjs:2:1122)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/something/dev/git/github/test2/connect-example/node_modules/@connectrpc/connect/dist/cjs/protocol-grpc/trailer-status.js:18:24)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Object.transformer (/Users/something/dev/git/github/test2/connect-example/node_modules/tsx/dist/register-C1urN2EO.cjs:2:1122)

Node.js v20.16.0

Environment (please complete the following information):

  • @connectrpc/connect-web version: -
  • @connectrpc/connect-node version: 1.4.0
  • Frontend framework and version: -
  • Node.js version: 20.16.0
  • Browser and version: -
@holomekc holomekc added the bug Something isn't working label Aug 4, 2024
@holomekc
Copy link
Author

holomekc commented Aug 4, 2024

Hmm I am stupid. It is because of 2.0.0 @bufbuild/protobuf... I should read first.

@holomekc holomekc closed this as completed Aug 4, 2024
@Evilu
Copy link

Evilu commented Aug 4, 2024

Hmm I am stupid. It is because of 2.0.0 @bufbuild/protobuf... I should read first.

how did you downgrade? all versions are now using protoc-gen-es v2.0.0 for some reason

@holomekc
Copy link
Author

holomekc commented Aug 4, 2024

I just specified 1.10.0 for all @bufbuild related deps in the package.json

@Evilu
Copy link

Evilu commented Aug 6, 2024

I just specified 1.10.0 for all @bufbuild related deps in the package.json

For the record, here's how things worked out for me.
TLDR:
Not really related to pacakge.json
As strange as it sounds, buf pulls code by itself and it overrides npm, you must specify in buf.gen.yaml the version you need.
bufbuild/protobuf-es#957

@smaye81
Copy link
Member

smaye81 commented Aug 6, 2024

Thanks for calling this out. We've updated our docs to pin the versions to v1.x, so hopefully they should work out of the box again.

https://connectrpc.com/docs/node/getting-started/

@jdms754
Copy link

jdms754 commented Sep 9, 2024

Are there plans to support @bufbuild/protobuf 2.0.0? Is it just a matter of updating peer dependencies?

@timostamm
Copy link
Member

@jdms754, the upcoming @connectrpc/connect v2 will support it. It's being worked on in the v2 branch, and it is available as a pre-release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants