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

Module not found: Can't resolve 'request' in '/vercel/path0/node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src #4987

Open
ollebergkvist opened this issue Jan 25, 2024 · 12 comments
Assignees

Comments

@ollebergkvist
Copy link

ollebergkvist commented Jan 25, 2024

I'm getting this error during build time using @google-cloud/tasks in a turborepo(monorepo).

It seems to be directly related to pnpm, I'm using @google-cloud/tasks in another Vercel project which uses yarn, and the error is not triggered during build in this case.

Is pnpm supported?

next:build:  ⚠ Compiled with warnings

next:build: 

next:build: ../../node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src/streamingRetryRequest.js

next:build: Module not found: Can't resolve 'request' in '/vercel/path0/node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src'

next:build: 

next:build: Import trace for requested module:

next:build: ../../node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src/streamingRetryRequest.js

next:build: ../../node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src/streamingCalls/streaming.js

next:build: ../../node_modules/.pnpm/google-gax@4.2.1_encoding@0.1.13/node_modules/google-gax/build/src/index.js

next:build: ../../node_modules/.pnpm/@google-cloud+tasks@4.0.1_encoding@0.1.13/node_modules/@google-cloud/tasks/build/src/v2beta2/cloud_tasks_client.js

next:build: ../../node_modules/.pnpm/@google-cloud+tasks@4.0.1_encoding@0.1.13/node_modules/@google-cloud/tasks/build/src/v2beta2/index.js

next:build: ../../node_modules/.pnpm/@google-cloud+tasks@4.0.1_encoding@0.1.13/node_modules/@google-cloud/tasks/build/src/index.js

next:build: ./app/api/crons/prepare-monitor/route.ts

Environment details

System:
OS: macOS 12.7.2
CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
Memory: 1.29 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.18.2 - ~/.asdf/installs/nodejs/lts/bin/node
npm: 9.8.1 - ~/.asdf/plugins/nodejs/shims/npm
pnpm: 8.11.0 - ~/.asdf/installs/nodejs/lts/bin/pnpm
Browsers:
Chrome: 120.0.6099.234
Safari: 17.2.1
npmPackages:
@google-cloud/tasks: ^4.0.1 => 4.0.1

Steps to reproduce

Please include any and all code and/or steps related to reproducing the bug.

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@ollebergkvist
Copy link
Author

I'm getting the error also after setting node-linker=hoisted in my .npmrc file

@ollebergkvist
Copy link
Author

ollebergkvist commented Jan 26, 2024

I just tried to use turborepo with yarn with this config:

yarnrc.yml

nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.4.1.cjs

Same error.

@sofisl sofisl self-assigned this Feb 5, 2024
@jgeschwendt
Copy link

jgeschwendt commented Feb 23, 2024

I hit this today, I'm using pnpm@v8 in a monorepo, running node@v20.11.0, pkg details are

"@google-cloud/recaptcha-enterprise": "5.3.0",
"next": "14.1.0"

stack:

../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingRetryRequest.js
Module not found: Can't resolve 'request' in '~/node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src'

Import trace for requested module:
../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingRetryRequest.js
../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingCalls/streaming.js
../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/index.js
../../node_modules/.pnpm/@google-cloud+recaptcha-enterprise@5.3.0/node_modules/@google-cloud/recaptcha-enterprise/build/src/v1beta1/recaptcha_enterprise_service_v1_beta1_client.js
../../node_modules/.pnpm/@google-cloud+recaptcha-enterprise@5.3.0/node_modules/@google-cloud/recaptcha-enterprise/build/src/v1beta1/index.js
../../node_modules/.pnpm/@google-cloud+recaptcha-enterprise@5.3.0/node_modules/@google-cloud/recaptcha-enterprise/build/src/index.js

@ollebergkvist
Copy link
Author

ollebergkvist commented Mar 4, 2024

For @google-cloud/tasks it's more complicated, it just continues with more modules missing after installing request
eg: "Error: Cannot find module '/app/node_modules/.pnpm/@Google-Cloud+tasks@5.1.1_encoding@0.1.13/node_modules/@google-cloud/tasks/build/esm/src/v2/cloud_tasks_client_config.json'"

@h36ahmed
Copy link

h36ahmed commented Mar 22, 2024

I am running into the same issue
import trace for requested module: ../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingRetryRequest.js ../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingCalls/streaming.js ../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/index.js ../../node_modules/.pnpm/@google-analytics+data@4.4.0/node_modules/@google-analytics/data/build/src/v1alpha/alpha_analytics_data_client.js ../../node_modules/.pnpm/@google-analytics+data@4.4.0/node_modules/@google-analytics/data/build/src/v1alpha/index.js ../../node_modules/.pnpm/@google-analytics+data@4.4.0/node_modules/@google-analytics/data/build/src/index.js ./src/app/api/analytics/route.ts ⚠ ../../node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src/streamingRetryRequest.js Module not found: Can't resolve 'request' in '/node_modules/.pnpm/google-gax@4.3.1/node_modules/google-gax/build/src'

@Naruto1200
Copy link

I'm also running into this problem with the google tasks library for node

Error: Cannot find module 'node_modules\@google-cloud\tasks\build\esm\src\v2\cloud_tasks_client_config.json'

I do not get this error if i downgrade to version 5.0.0. but anythging beyond this version triggers the error. I'm using NextJS 14

@alexxisroxxanne
Copy link

I am also getting this issue while trying to use Document AI:

Module not found: Can't resolve 'request' in '/node_modules/.pnpm/google-gax@4.3.2/node_modules/google-gax/build/src'

Import trace for requested module:
./node_modules/.pnpm/google-gax@4.3.2/node_modules/google-gax/build/src/streamingRetryRequest.js
./node_modules/.pnpm/google-gax@4.3.2/node_modules/google-gax/build/src/streamingCalls/streaming.js
./node_modules/.pnpm/google-gax@4.3.2/node_modules/google-gax/build/src/index.js
./node_modules/.pnpm/@google-cloud+documentai@8.2.0/node_modules/@google-cloud/documentai/build/src/v1beta1/document_understanding_service_client.js
./node_modules/.pnpm/@google-cloud+documentai@8.2.0/node_modules/@google-cloud/documentai/build/src/v1beta1/index.js
./node_modules/.pnpm/@google-cloud+documentai@8.2.0/node_modules/@google-cloud/documentai/build/src/index.js
./src/

@ollebergkvist
Copy link
Author

ollebergkvist commented Apr 14, 2024

@sofisl Hi! Hope you're well. Is there an ETA for when we might see a fix here? Many thanks in advance 🙏

@dstroot
Copy link

dstroot commented Apr 15, 2024

Has anyone tried just installing request? E.g. "pnpm add request"? It worked for me, although request is a long deprecated module.

@ollebergkvist
Copy link
Author

ollebergkvist commented Apr 15, 2024

Has anyone tried just installing request? E.g. "pnpm add request"? It worked for me, although request is a long deprecated module.

Yepp, the missing modules stack continues... at least for @google-cloud/tasks but I guess for some of the libs that might be a sufficient fix.

@sofisl
Copy link
Contributor

sofisl commented Apr 16, 2024

Sorry for the delay, I will take a look next week.

@sofisl
Copy link
Contributor

sofisl commented Apr 22, 2024

Ok after looking into this, there are two separate issues happening:

  1. The issue with Cloud Tasks and Next.js is a known issue with a workaround, please see here.
  2. We don't technically support pnpm because there are some discrepancies in how it installs modules (for example, not implicitly installing the highest version of a dependency with a caret). That being said, we actually use pnpm to install dependencies during tests, so this seemed a little weird to me. Since tests haven't failed, I attempted to reproduce with Node 18 and pnpm 8.6.10 locally, and was able to run our sample test successfully (after fixing some issues with the module resolution as described here). Are any of these issues occuring in just a Nodejs environment (without Vercel or Next.js?)

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

No branches or pull requests

7 participants