Home
Support Forums

Gatsby-starter-ghost template failed to deploy

Hi There,

I’m playing around with Netlify for the first time. I tried this template, but it doesn’t work as expected. The deploy failed with the following error message:

1:37:48 PM: $ NODE_ENV=production gatsby build
1:37:51 PM: error We encountered an error while trying to load your site’s gatsby-config. Please fix the error and try again.
1:37:51 PM:
1:37:51 PM: Error: siteUrl can’t be localhost and needs to be configured in siteConfig. Ch eck the README.

1:37:51 PM: - gatsby-config.js:26 Object.
1:37:51 PM: /opt/build/repo/gatsby-config.js:26:11
1:37:51 PM:
1:37:51 PM: - v8-compile-cache.js:178 Module._compile
1:37:51 PM: [repo]/[gatsby]/[v8-compile-cache]/v8-compile-cache.js:178:30
1:37:51 PM:
1:37:51 PM: - loader.js:1035 Object.Module._extensions…js
1:37:51 PM: internal/modules/cjs/loader.js:1035:10
1:37:51 PM:
1:37:51 PM: - loader.js:879 Module.load
1:37:51 PM: internal/modules/cjs/loader.js:879:32
1:37:51 PM:
1:37:51 PM: - loader.js:724 Function.Module._load
1:37:51 PM: internal/modules/cjs/loader.js:724:14
1:37:51 PM:
1:37:51 PM: - loader.js:903 Module.require
1:37:51 PM: internal/modules/cjs/loader.js:903:19
1:37:51 PM:
1:37:51 PM: - v8-compile-cache.js:159 require
1:37:51 PM: [repo]/[gatsby]/[v8-compile-cache]/v8-compile-cache.js:159:20
1:37:51 PM:
1:37:51 PM: - get-config-file.ts:30 getConfigFile
1:37:51 PM: [repo]/[gatsby]/src/bootstrap/get-config-file.ts:30:20
1:37:51 PM:
1:37:51 PM: - initialize.ts:113 initialize
1:37:51 PM: [repo]/[gatsby]/src/services/initialize.ts:113:50
1:37:51 PM:
1:37:51 PM: - index.ts:42 bootstrap
1:37:51 PM: [repo]/[gatsby]/src/bootstrap/index.ts:42:15
1:37:51 PM:
1:37:51 PM: - build.ts:93 build
1:37:51 PM: [repo]/[gatsby]/src/commands/build.ts:93:47
1:37:51 PM:
1:37:51 PM:
1:37:51 PM: not finished open and validate gatsby-configs - 0.142s
1:37:51 PM: ​
1:37:51 PM: ┌─────────────────────────────┐
1:37:51 PM: │ “build.command” failed │
1:37:51 PM: └─────────────────────────────┘
1:37:51 PM: ​
1:37:51 PM: Error message
1:37:51 PM: Command failed with exit code 1: NODE_ENV=production gatsby build
1:37:51 PM: ​
1:37:51 PM: Error location
1:37:51 PM: In build.command from netlify.toml:
1:37:51 PM: NODE_ENV=production gatsby build
1:37:51 PM: ​
1:37:51 PM: Resolved config
1:37:51 PM: build:
1:37:51 PM: command: NODE_ENV=production gatsby build
1:37:51 PM: commandOrigin: config
1:37:51 PM: publish: /opt/build/repo/public
1:37:51 PM: Caching artifacts
1:37:51 PM: Started saving node modules
1:37:51 PM: Finished saving node modules
1:37:51 PM: Started saving build plugins
1:37:51 PM: Finished saving build plugins
1:37:51 PM: Started saving yarn cache
1:37:51 PM: Finished saving yarn cache
1:37:51 PM: Started saving pip cache
1:37:51 PM: Finished saving pip cache
1:37:51 PM: Started saving emacs cask dependencies
1:37:51 PM: Finished saving emacs cask dependencies
1:37:51 PM: Started saving maven dependencies
1:37:51 PM: Finished saving maven dependencies
1:37:51 PM: Started saving boot dependencies
1:37:51 PM: Finished saving boot dependencies
1:37:51 PM: Started saving go dependencies
1:37:51 PM: Finished saving go dependencies
1:37:55 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:37:55 PM: Failing build: Failed to build site
1:37:55 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
1:37:55 PM: Finished processing build request in 1m15.105688611s

The site URL is: objective-kilby-d2e2d2.netlify.app.
The template claimed to be one click, so I didn’t change anything other than following the instructions to link to my github account. Please help.

Thanks

Try changing build command in netlify.toml to gatsby build. The file should look like this:

[build]
  command = "gatsby build"
  publish = "public/"

[template]
  incoming-hooks = ["Ghost"]

Thanks for the reply hrishikesh,

unfortunately, the one-click template failed to deploy, therefore, what you get is an empty Github repo with no access to files like netlify.toml at all.

I tried to fork the gatsby-starter-ghost repo, modified the netlify.toml file according to your reply, and linked the repo to a new netlify site. The deployment still failed. I have to manually change the siteUrl inside siteConfig.js from localhost to the netlify site URL, in order to get it finally working. I’m not a web developer, but it must be something wrong with the template. I hope it gets fixed soon.

Hi, @spikeliu1984. That template wasn’t created (and is not maintained) by Netlify. If you would like to see that template improved, it might help to file an issue on the repo itself here:

https://github.com/TryGhost/gatsby-starter-ghost/issues