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

Cannot find module '@google-cloud/tasks/build/protos/protos' #5058

Open
aphofstede opened this issue Feb 19, 2024 · 6 comments · Fixed by googleapis/gapic-generator-typescript#1543

Comments

@aphofstede
Copy link

aphofstede commented Feb 19, 2024

Environment details

  • which product (packages/*): Cloud Tasks
  • OS: macos
  • Node.js version: 21
  • npm version: 8
  • google-cloud-node version: 5.0.0

Steps to reproduce

Since v5, in TypeScript, resolve the google.cloud.tasks.v2.ITask interface from the package.

    Cannot find module '@google-cloud/tasks/build/protos/protos' from 'src/services/taskQueue/taskQueue.ts'

    Require stack:
       6 | import { CloudTasksClient } from '@google-cloud/tasks';
    >  7 | import { google } from '@google-cloud/tasks/build/protos/protos';
         | ^
       9 | import ITask = google.cloud.tasks.v2.ITask;
      10 |

      at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
      at Object.require (src/services/taskQueue/taskQueue.ts:7:1)

Seems to resolve fine in the IDE, but during TS compilation / Jest test run the error appears.

EDIT: Workaround: Use the namespaced type name directly, e.g.

    const task: google.cloud.tasks.v2.ITask = {
      httpRequest: {
      ...
@sofisl
Copy link
Contributor

sofisl commented Feb 22, 2024

Great, was able to reproduce. Submitted googleapis/gapic-generator-typescript#1543 as a fix.

@sofisl
Copy link
Contributor

sofisl commented Feb 27, 2024

@aphofstede, I've just released 5.1.1 which should contain the fix for this. Could I trouble you to give it a try and see if it works?

@aphofstede
Copy link
Author

Works. ty

@aphofstede
Copy link
Author

I think they got removed again

@aphofstede aphofstede reopened this Nov 6, 2024
@sofisl
Copy link
Contributor

sofisl commented Dec 6, 2024

Hm, I'm seeing it in the latest version, that code mentioned above only released the duplicate, see
Screenshot 2024-12-05 at 4 08 27 PM
if you're targeting esm, is it possible you need to add the full file path @google-cloud/tasks/build/protos/protos.js?

@vijayprakashpj
Copy link

@aphofstede I had the same problem and here is how I fixed it by changing the import statement.

import { protos } from '@google-cloud/tasks'

The types under google namespace are now accessible from protos.google.[...].
Hope this helps.

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

Successfully merging a pull request may close this issue.

3 participants