2

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.

Nouman Javed
  • 129
  • 1
  • 1
  • 13
  • 1
    It looks like the build might be failing because the queries took too long. See lines 141, 143 etc. I think exit code 137 is relating to running out of memory. Looks like your Contentful environment variables are fine because they're printed in the console above. I'm not sure currently how to solve the memory issue but maybe that points you in the right direction. – whitep4nth3r Jun 28 '21 at 08:30

2 Answers2

0

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

hgb123
  • 13,869
  • 3
  • 20
  • 38
  • I added the variables while creating the deploy, so I don't think that is the problem – Nouman Javed Jun 27 '21 at 19:52
  • @NoumanJaved did you get success when building locally? – hgb123 Jun 28 '21 at 15:06
  • 1
    @NoumanJaved could you temporarily remove `AVIF` in [this file](https://github.com/noumanmalik960/youshopweship/blob/master/src/components/carousel.js) and try pushing to netlify again? – hgb123 Jun 29 '21 at 06:54
  • It worked! can't believe it was this. Could you tell me why was this an issue? @hgb123 – Nouman Javed Jun 29 '21 at 09:08
  • @NoumanJaved AVIF transformation currently causes resource exceeded on Netlify, and they are still working on this. You could find more detail on [this post](https://answers.netlify.com/t/can-build-gatsby-site-locally-but-cant-on-netlify/34128/19) – hgb123 Jun 29 '21 at 10:06
  • Alright. you can post it as answer and Ill approve it if you want to @hgb123 – Nouman Javed Jun 29 '21 at 10:17
  • @NoumanJaved cool, I've just updated my answer – hgb123 Jun 29 '21 at 11:27
0

Try to profile your memory application if it's consuming a lot of memory during npm run build on your local setup. In my case it was peaking up to 1.5 GB and Netlify will trigger an error build during deployment.

Adjusting the CPU Count to a lower number did the trick for me. Site Settings > Build & deploy > Environment variable

GATSBY_CPU_COUNT = 2

Reference: https://www.gatsbyjs.com/docs/how-to/performance/resolving-out-of-memory-issues/#try-reducing-the-number-of-cores