0

When I attempt to deploy my gatsby.js site to Netlify, I get the following error/failure message:

7:27:09 AM: Error running command: Build script returned non-zero exit code: 1
7:27:09 AM: Failing build: Failed to build site
7:27:09 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
7:27:09 AM: Finished processing build request in 1m9.884654373s

I looked at the previous question about this issue, but I can't seem to get mine to work.

I pasted my package.json on JSONLine and got Valid JSON.

I can't seem to figure out the problem with this. Any help would be much appreciated.

Matt
  • 811
  • 2
  • 11
  • 20
  • Does `npm run build` work on your own machine? – Tholle Nov 03 '18 at 00:57
  • 1
    Can you post the error that created the exit code further up in your build log? – talves Nov 03 '18 at 16:04
  • You'd need to give more details to get the best answer. All of those lines are the SYMPTOM for the failure, not the cause. The cause is further up (whatever causes the build process to exit with a status code of 1). – fool Dec 26 '18 at 00:28

2 Answers2

1

Make sure all empty directories are going into your repository. There may be a missing path with reference to a missing directory in your repository.

example plugin in gatsby-config.js

{
  resolve: `gatsby-source-filesystem`,
  options: {
    path: `${__dirname}/src/img`,
    name: `images`,
  },
}

A common mistake is to add src/img to your local file system, but forget to commit it into your repository until you get images.

talves
  • 13,993
  • 5
  • 40
  • 63
1

tldr; add a .gitkeep file to your src/images folder if it is empty.

I encountered this same issue. Building locally worked, but deploying to Netlify failed for unknown reasons.

Turns out, the issue happened because I deleted the placeholder Gatsby images from src/images.

When I deleted the images, the folder was empty. Git ignores empty folders, so the next time I pushed to my remote repo, the src/images folder was removed.

But my gatsby-config file referenced src/images. That folder still existed when I ran build locally, but not in the remote version that Netlify was trying to deploy.

Anyway, adding a .gitkeep file to the src/images directory fixed the problem. .gitkeep tells Git to keep the directory (even though it's empty), which meant that Netlify was not trying to access a directory that did not exist.

Scott
  • 98
  • 4