question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error running with webpack: ENOENT: no such file or directory, open 'iam_service.json'

See original GitHub issue

Environment 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

  1. 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.

  1. 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.

  1. 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:closed
  • Created 2 years ago
  • Comments:26 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-fenstercommented, Apr 23, 2021

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.

1reaction
alexander-fenstercommented, Apr 23, 2021

@hgardneriv Before I start pushing the fix through several libraries, here’s the test version for you to check:

$ rm -rf package-lock.json node_modules
$ npm install @google-cloud/pubsub@load-proto-json

The following command should give the pre-released versions for these two packages:

$ npm ls @google-cloud/pubsub google-gax
pubsub-repro@ /Users/fenster/pubsub-repro
└─┬ @google-cloud/pubsub@2.11.1-pre
  └── google-gax@2.12.0-pre.1

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack: ENOENT: no such file or directory, open 'head.ejs'
When trying to load an ejs file that contains <% somefile %> the file cannot be found.. this is the error I receive:...
Read more >
Writefile No Such File Or Directory - ADocLib
Error running with webpack : ENOENT: no such file or directory open 'iamservice.json' OS: Linux & MacOS; Node.js version: v14.15.0; npm version: 6.14.8....
Read more >
webpack-dev-server - npm
Start using webpack-dev-server in your project by running `npm i ... -j, --json [value] Prints result as JSON or store it in a...
Read more >
express error: enoent: no such file or directory, stat - You.com
Alternatively, implement a gulp or grunt task that recursively copies all non-JavaScript, non-JSON and non-TypeScript files over to your TypeScript output ...
Read more >
troubleshooting.md - Webpacker Docs
Put a debugger statement in your Webpack configuration and run bin/webpack ... If you get the error ENOENT: no such file or directory...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found