Open
Description
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
- Create a project with the following package.json
{
"name": "test-spanner-nodejs",
"version": "1.0.0",
"dependencies": {
"@google-cloud/spanner": "^6.11.0"
},
"packageManager": "[email protected]"
}
yarn install
- 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")
})()
yarn node main.js
You should see the error above. Adding "protobufjs": "^7.2.3"
to the dependencies in package.json
fixes the problem.
Metadata
Metadata
Assignees
Labels
No labels