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

Missing transitive dependency on protobufjs #166

Open
maxmil opened this issue Jun 13, 2023 · 1 comment
Open

Missing transitive dependency on protobufjs #166

maxmil opened this issue Jun 13, 2023 · 1 comment

Comments

@maxmil
Copy link

maxmil commented Jun 13, 2023

When using the library with Yarn 3 (via google-cloud/spanner) module resolution is failing at runtime because protobufjs/minimal is referenced from build/src/generated/ but the transitive dependency on protobufjs is not declared in package json.

Error: grpc-gcp tried to access protobufjs, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: protobufjs (via "protobufjs/minimal")
Required by: grpc-gcp@npm:1.0.1 (via /.yarn/cache/grpc-gcp-npm-1.0.1-d26546ce0e-ad6608b982.zip/node_modules/grpc-gcp/build/src/generated/)

Require stack:
- .yarn/cache/grpc-gcp-npm-1.0.1-d26546ce0e-ad6608b982.zip/node_modules/grpc-gcp/build/src/generated/grpc_gcp.js
- .yarn/cache/grpc-gcp-npm-1.0.1-d26546ce0e-ad6608b982.zip/node_modules/grpc-gcp/build/src/index.js
- .yarn/cache/@google-cloud-spanner-npm-6.11.0-4009155329-6a21287f0f.zip/node_modules/@google-cloud/spanner/build/src/index.js
- workspaces/common/src/cloud-spanner.ts

Environment details

  • OS: Debian 12.0
  • Node.js version: 18.14.0
  • yarn version: 3.6.0
  • grpc-gcp version: 1.0.1

Steps to reproduce

  1. Create a project with the following package.json
{
"name": "test-spanner-nodejs",
"version": "1.0.0",
"dependencies": {
  "@google-cloud/spanner": "^6.11.0"
},
"packageManager": "yarn@3.6.0"
}
  1. yarn install
  2. Copy main.js
(async () => {
  const {Spanner} = require('@google-cloud/spanner');
  const spanner = new Spanner({projectId: 'your-project-id'});
  await spanner.instance("your-instance").database("your-database").run("select 1")
})()
  1. yarn node main.js

You should see the error above. Adding "protobufjs": "^7.2.3" to the dependencies in package.json fixes the problem.

@maxmil
Copy link
Author

maxmil commented Jun 14, 2023

The dependency is used on line 4 of src/generated/igrpc_gcp.js

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