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 build in production on Netlify #269

Closed
Phatza opened this issue Dec 5, 2022 · 4 comments
Closed

Cannot build in production on Netlify #269

Phatza opened this issue Dec 5, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Phatza
Copy link

Phatza commented Dec 5, 2022

Environment



Describe the bug

Hi !

I cannot build the project on Netlify. (check deploy log)
Seems to be related to @graphql-codegen/cli
Everything is fine on my computer running it in dev and build stage (thx to this glitch because i'm in Windows environment).

I've also tried using [email protected] latest version but still doesn't work.

Btw, i've uploaded the project without this module and the build stage on Netlify works properly.

Anyone has upload any project using this module on Netlify ?

Thx in advance,
Regards

Expected behaviour

Should deploy easily on Netlify with auto-detect

Reproduction

No response

Additional context

No response

Logs

5:31:28 PM: > postinstall
5:31:28 PM: > nuxt prepare
5:31:28 PM: [log] Nuxi 3.0.0
5:31:28 PM: [info] [nuxt:tailwindcss] Using default Tailwind CSS file from runtime/tailwind.css
5:31:30 PM: [error]
5:31:30 PM:         Failed to load schema from dbsMXA5srcHmJR@&:
5:31:30 PM:       Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:           - dbsMXA5srcHmJR@&
5:31:30 PM: Creating deploy upload records
5:31:30 PM:         Error:
5:31:30 PM:       Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:           - dbsMXA5srcHmJR@&
5:31:30 PM:     at prepareResult (file:https:///opt/build/repo/node_modules/@graphql-tools/load/esm/load-typedefs.js:88:15)
5:31:30 PM:     at loadTypedefs (file:https:///opt/build/repo/node_modules/@graphql-tools/load/esm/load-typedefs.js:40:20)
5:31:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
5:31:30 PM:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
5:31:30 PM:     at async loadSchema (file:https:///opt/build/repo/node_modules/@graphql-tools/load/esm/schema.js:12:21)
5:31:30 PM:     at async loadSchema (file:https:///opt/build/repo/node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:240:20)
5:31:30 PM:     at async file:https:///opt/build/repo/node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:809:54
5:31:30 PM:     at async file:https:///opt/build/repo/node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:808:43
5:31:30 PM:     at async file:https:///opt/build/repo/node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:682:11
5:31:30 PM:     at async Task.run (file:https:///opt/build/repo/node_modules/listr2/dist/index.js:960:11)
5:31:30 PM:     at async /opt/build/repo/node_modules/p-map/index.js:57:22
5:31:30 PM:         GraphQL Code Generator supports:
5:31:30 PM:           - ES Modules and CommonJS exports (export as default or named export "schema")
5:31:30 PM:           - Introspection JSON File
5:31:30 PM:           - URL of GraphQL endpoint
5:31:30 PM:           - Multiple files with type definitions (glob expression)
5:31:30 PM:           - String in config file
5:31:30 PM:         Try to use one of above options and run codegen again.
5:31:30 PM:   Failed to load schema from dbsMXA5srcHmJR@&:
5:31:30 PM:   Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:   - dbsMXA5srcHmJR@&
5:31:30 PM:   Error:
5:31:30 PM:   Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:   - dbsMXA5srcHmJR@&
5:31:30 PM:   at prepareResult (node_modules/@graphql-tools/load/esm/load-typedefs.js:88:15)
5:31:30 PM:   at loadTypedefs (node_modules/@graphql-tools/load/esm/load-typedefs.js:40:20)
5:31:30 PM:   at processTicksAndRejections (node:internal/process/task_queues:96:5)
5:31:30 PM:   at async loadSchema (node_modules/@graphql-tools/load/esm/schema.js:12:21)
5:31:30 PM:   at async loadSchema (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:240:20)
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:809:54
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:808:43
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:682:11
5:31:30 PM:   at async Task.run (node_modules/listr2/dist/index.js:960:11)
5:31:30 PM:   at async node_modules/p-map/index.js:57:22
5:31:30 PM:   GraphQL Code Generator supports:
5:31:30 PM:   - ES Modules and CommonJS exports (export as default or named export "schema")
5:31:30 PM:   - Introspection JSON File
5:31:30 PM:   - URL of GraphQL endpoint
5:31:30 PM:   - Multiple files with type definitions (glob expression)
5:31:30 PM:   - String in config file
5:31:30 PM:   Try to use one of above options and run codegen again.
5:31:30 PM:   at executeCodegen (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:953:20)
5:31:30 PM:   at processTicksAndRejections (node:internal/process/task_queues:96:5)
5:31:30 PM:   at async generate (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:1254:23)
5:31:30 PM:   at async generate (node_modules/nuxt-graphql-client/dist/module.mjs:62:10)
5:31:30 PM:   at async generateGqlTypes (node_modules/nuxt-graphql-client/dist/module.mjs:334:46)
5:31:30 PM:   at async setup (node_modules/nuxt-graphql-client/dist/module.mjs:427:5)
5:31:30 PM:   at async normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:5)
5:31:30 PM:   at async installModule (node_modules/@nuxt/kit/dist/index.mjs:416:3)
5:31:30 PM:   at async initNuxt (node_modules/nuxt/dist/index.mjs:1825:7)
5:31:30 PM:   at async loadNuxt (node_modules/nuxt/dist/index.mjs:1857:5)
5:31:30 PM:   at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
5:31:30 PM:   at async Object.invoke (node_modules/nuxi/dist/chunks/prepare.mjs:30:18)
5:31:30 PM:   at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
5:31:30 PM:   Error:
5:31:30 PM:   Failed to load schema from dbsMXA5srcHmJR@&:
5:31:30 PM:   Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:   - dbsMXA5srcHmJR@&
5:31:30 PM:   Error:
5:31:30 PM:   Unable to find any GraphQL type definitions for the following pointers:
5:31:30 PM:   - dbsMXA5srcHmJR@&
5:31:30 PM:   at prepareResult (node_modules/@graphql-tools/load/esm/load-typedefs.js:88:15)
5:31:30 PM:   at loadTypedefs (node_modules/@graphql-tools/load/esm/load-typedefs.js:40:20)
5:31:30 PM:   at processTicksAndRejections (node:internal/process/task_queues:96:5)
5:31:30 PM:   at async loadSchema (node_modules/@graphql-tools/load/esm/schema.js:12:21)
5:31:30 PM:   at async loadSchema (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:240:20)
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:809:54
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:808:43
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:682:11
5:31:30 PM:   at async Task.run (node_modules/listr2/dist/index.js:960:11)
5:31:30 PM:   at async node_modules/p-map/index.js:57:22
5:31:30 PM:   GraphQL Code Generator supports:
5:31:30 PM:   - ES Modules and CommonJS exports (export as default or named export "schema")
5:31:30 PM:   - Introspection JSON File
5:31:30 PM:   - URL of GraphQL endpoint
5:31:30 PM:   - Multiple files with type definitions (glob expression)
5:31:30 PM:   - String in config file
5:31:30 PM:   Try to use one of above options and run codegen again.
5:31:30 PM:   at loadSchema (node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:248:11)
5:31:30 PM:   at processTicksAndRejections (node:internal/process/task_queues:96:5)
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:809:54
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:808:43
5:31:30 PM:   at async node_modules/@graphql-codegen/cli/dist/shared/graphql-codegen-cli-nuxt.111a00cc.mjs:682:11
5:31:30 PM:   at async Task.run (node_modules/listr2/dist/index.js:960:11)
5:31:30 PM:   at async node_modules/p-map/index.js:57:22
5:31:30 PM: npm ERR! code 1
5:31:30 PM: npm ERR! path /opt/build/repo
5:31:30 PM: npm ERR! command failed
5:31:30 PM: npm ERR! command sh -c -- nuxt prepare
5:31:30 PM: npm ERR! A complete log of this run can be found in:
5:31:30 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-12-05T16_31_20_197Z-debug-0.log
5:31:30 PM: Error during NPM install
5:31:30 PM: Build was terminated: Build script returned non-zero exit code: 1
5:31:30 PM: Failing build: Failed to build site
5:31:30 PM: Finished processing build request in 16.666035222s
@Phatza Phatza added the bug Something isn't working label Dec 5, 2022
@Diizzayy Diizzayy self-assigned this Dec 5, 2022
@Diizzayy
Copy link
Owner

Diizzayy commented Dec 5, 2022

@Phatza Thank you for raising this issue, I'll have a look into it.

In the meantime, can you give the codegen.disableOnBuild flag a try and let me know if it makes a difference.

@Phatza
Copy link
Author

Phatza commented Dec 6, 2022

Hi @Diizzayy,

I've tried many things and all results are the same.

My nuxt.config.ts when i've created this issue :

runtimeConfig: {
    public: {
      "graphql-client": {
        clients: {
          default: {
            retainToken: true,
          },
        },
      },
    },
  },

then when you asked me to try with codegen.disableOnBuild flag :

runtimeConfig: {
    public: {
      "graphql-client": {
        codegen: {
          disableOnBuild: true
        },
        clients: {
          default: {
            retainToken: true,
          },
        },
      },
    },
  },

This is the build log on Netlify :

11:16:44 AM: > postinstall
11:16:44 AM: > nuxt prepare
11:16:44 AM: [log] Nuxi 3.0.0
11:16:45 AM: [info] [nuxt:tailwindcss] Using default Tailwind CSS file from runtime/tailwind.css
11:16:46 AM: [error] GraphQL client (default) is missing it's host.
  at setup (node_modules/nuxt-graphql-client/dist/module.mjs:281:15)
11:16:46 AM:   at normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:29)
11:16:46 AM:   at async installModule (node_modules/@nuxt/kit/dist/index.mjs:416:3)
11:16:46 AM:   at async initNuxt (node_modules/nuxt/dist/index.mjs:1825:7)
11:16:46 AM: Creating deploy upload records
11:16:46 AM:   at async loadNuxt (node_modules/nuxt/dist/index.mjs:1857:5)
11:16:46 AM:   at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:493:19)
11:16:46 AM:   at async Object.invoke (node_modules/nuxi/dist/chunks/prepare.mjs:30:18)
11:16:46 AM:   at async _main (node_modules/nuxi/dist/cli.mjs:50:20)
11:16:46 AM: npm ERR! code 1
11:16:46 AM: npm ERR! path /opt/build/repo
11:16:46 AM: npm ERR! command failed
11:16:46 AM: npm ERR! command sh -c -- nuxt prepare
11:16:47 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
11:16:46 AM: npm ERR! A complete log of this run can be found in:
11:16:46 AM: npm ERR!     /opt/buildhome/.npm/_logs/2022-12-06T10_16_30_658Z-debug-0.log
11:16:46 AM: Error during NPM install
11:16:46 AM: Build was terminated: Build script returned non-zero exit code: 1
11:16:47 AM: Failing build: Failed to build site
11:16:47 AM: Finished processing build request in 21.556924282s

Then I've tried to force client host in config :

runtimeConfig: {
    public: {
      "graphql-client": {
        codegen: {
          disableOnBuild: true
        },
        clients: {
          default: {
            host: process.env.GQL_HOST, 
            token: process.env.GQL_TOKEN,
            retainToken: true,
          },
        },
      },
    },
  },

and finaly tried to turn codegen to false in 2 ways :

First

runtimeConfig: {
   public: {
     "graphql-client": {
       codegen: false,
       clients: {
         default: {
           host: process.env.GQL_HOST
           clientHost: process.env.GQL_HOST,
           retainToken: true,
         },
       },
     },
   },
 },

Second

runtimeConfig: {
   public: {
     "graphql-client": {
       codegen: false,
       clients: {
         default: {
           retainToken: true,
         },
       },
     },
   },
 },

All tests on Netlify result to the same build log (that you can see above)
But in local everything works fine

@Diizzayy
Copy link
Owner

Diizzayy commented Dec 7, 2022

@Phatza I can confirm that deployments to netlify do infact work with this module (Demo here of https://github.com/Diizzayy/nuxt-graphql-client-demo), so It's a bit strange that you've hit this roadblock. Upon inspecting the logs you added above, it appears that the nuxt app is failing to read your environment variables, even when passed directly using process.env

@Phatza
Copy link
Author

Phatza commented Dec 7, 2022

@Diizzayy thx for your reply.
I can confirm that it works !

After you told me about codegen.disableOnBuild flag, i made my tried based on a new fresh netlify instance and i didnt add env variables (mb ^^). that's why the deploy log printed : [error] GraphQL client (default) is missing it's host.

Conclusion:
If you have trouble deploying on Netlify, try this codegen: { disableOnBuild: true } or codegen: false

@Phatza Phatza closed this as completed Dec 7, 2022
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

2 participants