googleapis / googleapis/google-cloud-node

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

Open
#5,058 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

#### 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: {
...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.