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 'graphql-request' or its corresponding type declarations" when using with pnpm #471

Open
some-user123 opened this issue Mar 4, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@some-user123
Copy link

some-user123 commented Mar 4, 2024

Environment


  • Operating System: Windows_NT
  • Node Version: v20.11.1
  • Nuxt Version: 3.10.3
  • CLI Version: 3.10.1
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, modules, graphql-client
  • Runtime Modules: [email protected]
  • Build Modules: -

Describe the bug

After updating nuxt from 3.9.3 to 3.10.3 I'm getting this error:

$ pnpm typecheck

> nuxt-app@ typecheck C:\...\nuxt3-2024-03-02
> nuxt typecheck

.nuxt/gql/default.ts:1:52 - error TS2307: Cannot find module 'graphql-request' or its corresponding type declarations.

1 import type { GraphQLClient, RequestOptions } from 'graphql-request';
                                                     ~~~~~~~~~~~~~~~~~

.nuxt/gql/default.ts:2:21 - error TS2307: Cannot find module 'graphql-request' or its corresponding type declarations.

2 import { gql } from 'graphql-request';
                      ~~~~~~~~~~~~~~~~~


Found 2 errors in the same file, starting at: .nuxt/gql/default.ts:1


 ERROR  Command failed with exit code 2: vue-tsc --noEmit                                                                                                                                        21:52:41

  at makeError (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/index3.mjs:1259:11)
  at handlePromise (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/index3.mjs:2497:26)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Object.run (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/chunks/typecheck.mjs:73:7)
  at async runCommand$1 (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.a9f3bca7.mjs:1648:16)
  at async runCommand$1 (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.a9f3bca7.mjs:1639:11)
  at async runMain$1 (/C:/.../nuxt3-2024-03-02/node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.a9f3bca7.mjs:1777:7)



 ERROR  Command failed with exit code 2: vue-tsc --noEmit                                                                                                                                        21:52:41

 ELIFECYCLE  Command failed with exit code 1.

Expected behaviour

Should not fail ;-)

Reproduction

https://github.com/some-user123/nuxt-graphql-client-issue-471

  1. pnpm install --frozen-lockfile
  2. pnpm prepare
  3. pnpm typecheck

https://github.com/some-user123/nuxt-graphql-client-issue-471/actions/runs/8152835329/job/22283031110

Additional context

No response

Logs

No response

@some-user123 some-user123 added the bug Something isn't working label Mar 4, 2024
@Diizzayy Diizzayy self-assigned this Mar 5, 2024
@Diizzayy
Copy link
Owner

Diizzayy commented Mar 5, 2024

@some-user123 This was caused due to upstream changes in the graphql-request package (graffle-js/graffle#616), hence the dependencies for this module need to be updated.

For the time being you can manually install the dep as seen below to avoid the error:
pnpm add -D @graphql-codegen/[email protected]

@some-user123
Copy link
Author

I was withholding nuxt updates so far because I don't like workarounds ;-) (In some weeks nobody knows, why the package was added and it will stay there forever...)

When can we expect a solution? Wouldn't it just be an update to the package.json of nuxt-graphql-client?

Meanwhile graphql-request 7 was released which causes module resolution issues - not sure, if this is related.

@dimitriaatos
Copy link

@some-user123
For the time being you can manually install the dep as seen below to avoid the error: pnpm add -D @graphql-codegen/[email protected]

I'm still getting the error about graphql-request after trying this workaround.


  • Operating System: Darwin
  • Node Version: v20.11.0
  • Nuxt Version: 3.12.3
  • CLI Version: 3.12.0
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: devtools, compatibilityDate, modules, typescript
  • Runtime Modules: [email protected]
  • Build Modules: -

package.json

  "devDependencies": {
    "@graphql-codegen/typescript-graphql-request": "6.2.0"
  }
pnpm dev

> nuxt-app@ dev /...
> nuxt dev

Nuxt 3.12.3 with Nitro 2.9.7                                                                                             01:57:09
                                                                                                                         01:57:09
  ➜ Local:    https://localhost:3000/
  ➜ Network:  use --host to expose

  ➜ DevTools: press Shift + Option + D in the browser (v1.3.9)                                                           01:57:14

✔ Nuxt Nitro server built in 3056 ms                                                                              nitro 01:57:23
ℹ Vite client warmed up in 8491ms                                                                                       01:57:24
ℹ Vite server warmed up in 9043ms                                                                                       01:57:24

 ERROR                                                                                                                   01:57:25
 **ERROR(vue-tsc)  Cannot find module 'graphql-request' or its corresponding type declarations.**

@AngeloSchulerPiletti
Copy link

AngeloSchulerPiletti commented Jul 29, 2024

I am facing the same problem. I tried the solution proposed by @Diizzayy without success.

Furthermore, I also tried installed the "missing" packages without success.

Does anyone found a workaround for it?

@premdasvm
Copy link

@AngeloSchulerPiletti , @Diizzayy
I'm having the same issue, Installing graphql-request as a dev dependency seem to fix my issue, i'm not sure if it's the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants