Error running with webpack: ENOENT: no such file or directory, open 'iam_service.json'
See original GitHub issueEnvironment details
- OS: Linux & MacOS
- Node.js version: v14.15.0
- npm version: 6.14.8
@google-cloud/pubsub
version: 2.10.0
Steps to reproduce
- When running a pubsub consumer or producer with webpack, the following error occurs:
"err":{"message":"ENOENT: no such file or directory, open 'iam_service.json'"," stack":"Error: ENOENT: no such file or directory, open 'iam_service.json'\n at Object.openSync (fs.js:476:3)\n at Object.readFileSync (fs.js:377:35)\n at fetch (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403345:34) at Root.load (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403379:13) at Root.loadSync (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:403420:17) at Object.loadSync (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:105027:29) at GrpcClient.loadFromProto (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245393:48) at GrpcClient.loadProto (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245434:21) at new IamClient (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245684:38) at new SubscriberClient (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:86374:26)"
NOTE: This issue only happens when running with webpack, it works expected when webpack is not in use.
- This problem can be worked around by creating directory …/…/protos and place the following files in it:
$ ls …/…/protos iam_service.json protos.json
Unfortunately …/…/protos falls one level up of our install directory, so it’s not a valid work around.
- Using the {fallback: true} option in the PubSub constructor, as suggested in this post: https://github.com/googleapis/google-cloud-node/issues/2933, results in another error:
`“fetch is not a function”,“stack”:"TypeError: fetch is not a function at Service.newServiceStub.<computed> [as testIamPermissions] (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244522:17) at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:245730:29 at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:246661:16 at OngoingCall.call (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244030:27) at NormalApiCaller.call (/Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:246452:19) at /Users/harrygardner/Documents/code/cribl/dist/sluice/bin/cribl.bundle.js:244163:30\n at processTicksAndRejections (internal/process/task_queues.js:93:5)
Is there a work around for this issue?
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (13 by maintainers)
Top GitHub Comments
Thank you! I’ll go ahead and push this changes to the generator and
google-gax
. The wheels will start turning today and the releases will likely come out early next week.@hgardneriv Before I start pushing the fix through several libraries, here’s the test version for you to check:
The following command should give the pre-released versions for these two packages:
With these versions, I’m able to run the test code both with and without
webpack
. Could you please check that this fix works for you?Thank you!