Error: Cannot find module Next.js 14 when module exists #64765
-
SummaryI get this error in dev mode and when building my Next.js app locally or on Vercel, but also in dev mode. Error: Cannot find module 'C:\Projects\project\node_modules@google-cloud\tasks\build\esm\src\v2\cloud_tasks_client_config.json' Here is what I have tried:
Here is a minimal reproduce of the problem:
My next.config.mjs doesn't contain any webpack configurations. Here is the package.json:
When I click on the 'C:\Projects\project\node_modules@google-cloud\tasks\build\esm\src\v2\cloud_tasks_client_config.json file, it leads me to the right json file inside of node_modules, so the file exists. Additional informationNo response ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
After I have tried multiple versions of I even played around with the Changing the This module always seems to have issues, I recommend staying away from it. to fix this, run:
|
Beta Was this translation helpful? Give feedback.
-
wow, ty ty ty |
Beta Was this translation helpful? Give feedback.
-
any updates on this? i assume it's just the import routes are a bit off so you kind of need to copy this file over to root during the build process |
Beta Was this translation helpful? Give feedback.
-
I have the same issue with "@google-cloud/tasks": "5.1.0" and "next": "15.3.0-canary.10". Locally everything works fine, but on Vercel it breaks with Error: ENOENT: no such file or directory, open '/vercel/path0/node_modules/@google-cloud/tasks/build/esm/src/v2/cloud_tasks_client_config.json' |
Beta Was this translation helpful? Give feedback.
-
This workaround is currently working for me: task file:
next.config.js:
|
Beta Was this translation helpful? Give feedback.
After I have tried multiple versions of
Next.js
and multiple different versions of@google-cloud/tasks
, the issue persisted locally and on Vercel.I even played around with the
next.config.mjs
webpack config, and cleared cache, and deletednode_modules
multiple times.Changing the
@google-cloud/tasks
version to5.1.0
fixed the issue.This module always seems to have issues, I recommend staying away from it. to fix this, run:
npm i @google-cloud/[email protected]