Search code examples
reactjsgatsbynetlifycontentful

netlify deployment build is failing for gatsby-contentful site


I'm trying to deploy a Gatsby-Contentful site to Netlify and while deploying it gives me build error. While testing in localhost its working perfect. Here is the screenshot of the error:

netlify build error

While in production the npm run build command is working perfect.

I have tried this solution but it doesn't solve the issue. Invalid plugin options for "gatsby-source-contentful"

Link to the code on github is Here

I think there is something wrong with the contentful API keys while deploying but I can't figure out what is it.


Solution

  • You must setup environment variable on Netlify

    Netlify environment variables are accessible during your build. This allows you to change behaviors based on deploy parameters or to include information you don’t want to save in your repository

    Go to your site > Site Settings > Build & deploy > Environment variable, and add your variables

    enter image description here

    More details in this doc


    Update 2021-06-29

    The problem turned out to be process killed while querying during build on Netlify. AVIF transformation while querying gastby image data causes resource exceeded on Netlify. Netlify team and Gatsby are still working on this.

    The temporary solution now is to exclude AVIF from query.

    Discussion post