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

When nuxt-graphql-client is defined in modules, it throws a TS error on npm run dev when .nuxt is removed #218

Closed
TheDutchCoder opened this issue Oct 6, 2022 · 8 comments
Assignees

Comments

@TheDutchCoder
Copy link
Contributor

TheDutchCoder commented Oct 6, 2022

When you remove the .nuxt folder (e.g. with npx nuxi clean) and try to start dev mode, this plugin crashes because it's trying to run TS before the .nuxt folder is generated.

It looks like this module is running some typescript compilation before the .nuxt folder is generated, and since tsconfig.json depends on a config file in .nuxt, it will fail to run at all:

  error TS5083: Cannot read file '.nuxt/tsconfig.json'.

  at createTSError (node_modules/ts-node/src/index.ts:859:12)
  at reportTSError (node_modules/ts-node/src/index.ts:863:19)
  at createFromPreloadedConfig (node_modules/ts-node/src/index.ts:874:36)
  at create (node_modules/ts-node/src/index.ts:624:10)
  at register (node_modules/ts-node/src/index.ts:591:15)
  at TypeScriptLoader (node_modules/cosmiconfig-typescript-loader/dist/cjs/index.js:52:54)
  at node_modules/@graphql-codegen/cli/esm/config.js:16:18
  at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
  at async Promise.all (index 0)
  at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
  at async normalizeModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:476:26)
  at async installModule (node_modules/nuxt/node_modules/@nuxt/kit/dist/index.mjs:455:41)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:1606:7)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6778:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6828:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
@p3t3r67x0
Copy link

same here

@grmiranda
Copy link

Same here..
the problems here appears to be with the codegen config file

@itzaks
Copy link

itzaks commented Oct 11, 2022

I managed to go around this issue by creating a specific tsconfig.json for graphql-codegen's ts-node to load.

package.json

  "scripts": {
    "dev": "TS_NODE_PROJECT=./graphql.tsconfig.json nuxt dev",

graphql.tsconfig.json

{}

@Diizzayy Diizzayy self-assigned this Oct 11, 2022
@Diizzayy
Copy link
Owner

@TheDutchCoder @p3t3r67x0 @itzaks

This is a strange occurrence, when nuxi dev is ran it should regenerate the .nuxt directory before attempting to setup any modules.

I've been unable to reproduce this behavior due to the aforementioned.

Would you guys be able to provide additional details so I can further investigate why this happens? running npx nuxi info and posting the output should be suffice. A minimal reproduction would be welcomed as well.

@p3t3r67x0
Copy link

@Diizzayy thanks for reply

Repo to reproduce
https://github.com/p3t3r67x0/nuxt-rc-netlify

Some more details, fyi I changed the user names in output due to privacy reasons.

Steps to reproduce

git reset --hard HEAD
rm -r node_modules pnpm-lock.yaml
pnpm install --shamefully-hoist
pnpm run build
pnpm dlx nuxi info

Nuxi info output

pnpm dlx nuxi info

.../share/pnpm/store/v3/tmp/dlx-17799    |   +1 +
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /home/xxxx/.local/share/pnpm/store/v3
  Virtual store is at:             ../../.local/share/pnpm/store/v3/tmp/dlx-17799/node_modules/.pnpm
.../share/pnpm/store/v3/tmp/dlx-17799    | Progress: resolved 2, reused 1, downloaded 0, added 1, done
Nuxi 3.0.0-rc.11                                                                                                                               10:44:27
RootDir: /home/xxxx/git/shop-frontend-migration                                                                                            10:44:27
Nuxt project info:                                                                                                                             10:44:27

------------------------------
- Operating System: `Linux`
- Node Version:     `v16.17.1`
- Nuxt Version:     `3.0.0-rc.11`
- Nitro Version:    `0.5.4`
- Package Manager:  `pnpm@7.13.3`
- Builder:          `vite`
- User Config:      `-`
- Runtime Modules:  `-`
- Build Modules:    `-`
------------------------------

👉 Report an issue: https://github.com/nuxt/framework/issues/new

👉 Suggest an improvement: https://github.com/nuxt/framework/discussions/new

👉 Read documentation: https://v3.nuxtjs.org

@Diizzayy
Copy link
Owner

@p3t3r67x0 Thank you for the reproduction details ( it worked ) , I'll investigate further into it and update this issue accordingly.

@Diizzayy
Copy link
Owner

@TheDutchCoder @p3t3r67x0 This issue was caused by upstream changes to the @graphql-codegen/cli package. Version.

I've just released v0.1.23 for this module which resolves the aforementioned dependency to the last working version as a temporary fix for this issue.

@Diizzayy
Copy link
Owner

Track this issue in #242

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

5 participants