googleapis / google-cloud-node

Google Cloud Client Library for Node.js
https://cloud.google.com/nodejs
Apache License 2.0
2.92k stars 594 forks source link

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

Open aphofstede opened 8 months ago

aphofstede commented 8 months ago

Environment details

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 commented 8 months ago

Great, was able to reproduce. Submitted https://github.com/googleapis/gapic-generator-typescript/pull/1543 as a fix.

sofisl commented 8 months ago

@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 commented 8 months ago

Works. ty

aphofstede commented 1 week ago

I think they got removed again