5

I recently came across Gatsby JS (https://github.com/gatsbyjs/gatsby) and decided to build my portfolio site on top of the generator.

So I forked their starter site (gatsby-starter-default) and built my portfolio with it (https://github.com/ArchieHicklin/Archie)

Locally (using 'gatsby develop') it runs fine - but when I deploy to Netlify with 'gatsby build' I get this error:

11:30:58 AM: Build started
11:30:59 AM: Fetching cached dependencies
11:30:59 AM: Expected build cache - but failed to find it
11:30:59 AM: No cached dependencies found. Cloning fresh repo
11:30:59 AM: git clone git@github.com:ArchieHicklin/Archie /mnt/build-work/1475033459125476884/repo
11:31:00 AM: git remote rm origin /mnt/build-work/1475033459125476884/repo
11:31:00 AM: Preparing Branch
11:31:01 AM: Building site
11:31:01 AM: Running build command
11:31:02 AM: Running Build
11:31:02 AM: Building
11:31:03 AM: 0.0%
11:31:03 AM: 1.2%
11:31:04 AM: ## 3.6%
11:31:04 AM: ##### 7.
11:31:04 AM: 0%
11:31:04 AM: ######## 12.5%
11:31:04 AM: ##############
11:31:04 AM:
11:31:04 AM: 20.7%
11:31:04 AM: ###################
11:31:04 AM: 27.0%
11:31:04 AM: ############################### 44.3%
11:31:04 AM: ################################################## 70.0%
11:31:04 AM: ############################################################# 86.1%
11:31:04 AM: ########################################################################
11:31:04 AM: 100.0%
11:31:05 AM: 
11:31:05 AM: Computing checksum with sha256sum
11:31:05 AM: Checksums matched!
11:31:06 AM: Using version v4.4.2 of node
11:31:06 AM: Using /opt/buildhome/.rvm/gems/ruby-2.1.2
11:31:06 AM: Installing npm modules
11:31:07 AM: NPM modules installed
11:31:08 AM: /opt/build/build.sh: line 232: gatsby: command not found
11:31:08 AM: Cached node modules
11:31:08 AM: Cleaning up docker container
11:31:08 AM: Error running command: Build script returned non-zero exit code: 127
11:31:08 AM: Error running command: Build script returned non-zero exit code: 127

Have done all the standard things like reinstall node and npm (as I thought it may be an issue) but, after a few weeks, I am absolutely stumped as to what the issue is. Likewise, there isn't a huge amount of documentation online so fairly stuck as to where to even start with tackling this issue.

Any help (even pointers in where to start re debugging) would be really really appreciated!

Archie
  • 97
  • 1
  • 2
  • 6

2 Answers2

4

Check if you have package-lock.json file commited to your code repository. If so, delete it from the repo, and trigger the deploy again. Netlify build fails when it finds package-lock.json

Nagesh Andani
  • 432
  • 6
  • 12
  • **WARNING** : delete `package-lock.json` can affect all the project in really bad way. https://stackoverflow.com/questions/54124033/deleting-package-lock-json-to-resolve-conflicts-quickly/54127283 – Marzieh Mousavi Jan 27 '22 at 10:49
1

The build log is complaining that gatsby is not installed, so make sure to add gatsby to your package.json as a dependency.

Simplest way is to run:

npm install gatsby --save

Locally and then add the updated package.json to your repository. That way netlify will know to install gatsby before running your build command.

Biilmann
  • 41
  • 4
  • He does seem to have Gatsby installed... https://github.com/ArchieHicklin/Archie/blob/bb11af47cf4ce2e1c7ae4d2c4298309140a5fcb3/package.json#L16 – Kyle Mathews Sep 28 '16 at 04:01
  • Looks like the package.json is a bit off - all the dependencies are nested under the `repository` attribute: https://github.com/ArchieHicklin/Archie/blob/bb11af47cf4ce2e1c7ae4d2c4298309140a5fcb3/package.json#L9 That's why Gatsy doesn't get installed – Biilmann Sep 28 '16 at 04:26
  • Thanks for these responses! Ran {npm install gatsby --save} and still have the same exit code. Should those things not be nested under dependency in the package.json? https://github.com/ArchieHicklin/Archie/blob/master/package.json – Archie Sep 28 '16 at 06:13
  • Yeah exactly. Close out the repository subobject. Right now you don't have a top-level `dependencies` key which Netlify needs. – Kyle Mathews Sep 28 '16 at 23:12
  • If you paste your package.json in http://jsonlint.com/ it's easier to see what's wrong. – Kyle Mathews Sep 28 '16 at 23:12
  • Closing and unnesting the repository object was what did it - through some errors in deployment but seems to be now live and working! – Archie Sep 29 '16 at 06:53