[Gatsby] Ghost Blog Starter "WebpackError: TypeError: Cannot read property 'node' of undefined"

ecstatic-wiles-8783b8.netlify.app

I’ve used the Gatsby starter ghost blog made all changes exactly as suggested in the read me file, all seems fine locally but I cannot get Netlify to build it

Important part of BUILD LOG:


3:21:52 AM: failed Building static HTML for pages - 2.583s
3:21:52 AM: error Building static HTML failed for path "/"
3:21:52 AM: 
3:21:52 AM:   24 |     const canonical = url.resolve(config.siteUrl, location.pathname)
3:21:52 AM:   25 |     const { ghostPost, ghostTag, ghostAuthor, ghostPage } = data
3:21:52 AM: > 26 |     settings = settings.allGhostSettings.edges[0].node
3:21:52 AM:      |                                                   ^
3:21:52 AM:   27 |
3:21:52 AM:   28 |     if (ghostPost) {
3:21:52 AM:   29 |         return (
3:21:52 AM: 
3:21:52 AM:   WebpackError: TypeError: Cannot read property 'node' of undefined
3:21:52 AM:   
3:21:52 AM:   - MetaData.js:26 
3:21:52 AM:     gatsby-starter-ghost/src/components/common/meta/MetaData.js:26:51
3:21:52 AM:   
3:21:52 AM:   - extends.js:3 
3:21:52 AM:     [gatsby-starter-ghost]/[@babel]/runtime/helpers/extends.js:3:42
3:21:52 AM:   
3:21:52 AM:   - extends.js:2 
3:21:52 AM:     [gatsby-starter-ghost]/[@babel]/runtime/helpers/extends.js:2:1
3:21:52 AM:   
3:21:52 AM:   - extends.js:13 
3:21:52 AM:     [gatsby-starter-ghost]/[@babel]/runtime/helpers/extends.js:13:1
3:21:52 AM:   
3:21:52 AM:   - static-entry.js:263 
3:21:52 AM:     gatsby-starter-ghost/.cache/static-entry.js:263:20
3:21:52 AM:   
3:21:52 AM: 
3:21:52 AM: not finished Caching JavaScript and CSS webpack compilation - 5.608s
3:21:52 AM: not finished Caching HTML renderer compilation - 2.617s
3:21:52 AM: ​
3:21:52 AM: ────────────────────────────────────────────────────────────────
3:21:52 AM:   "build.command" failed                                        
3:21:52 AM: ────────────────────────────────────────────────────────────────
3:21:52 AM: ​
3:21:52 AM:   Error message
3:21:52 AM:   Command failed with exit code 1: NODE_ENV=production gatsby build
3:21:52 AM: ​
3:21:52 AM:   Error location
3:21:52 AM:   In build.command from netlify.toml:
3:21:52 AM:   NODE_ENV=production gatsby build
3:21:52 AM: ​
3:21:52 AM:   Resolved config
3:21:52 AM:   build:
3:21:52 AM:     command: NODE_ENV=production gatsby build
3:21:52 AM:     commandOrigin: config
3:21:52 AM:     publish: /opt/build/repo/public
3:21:52 AM:     publishOrigin: config
3:21:52 AM:   functions:
3:21:52 AM:     '*': {}
3:21:53 AM: Caching artifacts
3:21:53 AM: Started saving node modules
3:21:53 AM: Finished saving node modules
3:21:53 AM: Started saving build plugins
3:21:53 AM: Finished saving build plugins
3:21:53 AM: Started saving pip cache
3:21:53 AM: Finished saving pip cache
3:21:53 AM: Started saving emacs cask dependencies
3:21:53 AM: Finished saving emacs cask dependencies
3:21:53 AM: Started saving maven dependencies
3:21:53 AM: Finished saving maven dependencies
3:21:53 AM: Started saving boot dependencies
3:21:53 AM: Finished saving boot dependencies
3:21:53 AM: Started saving rust rustup cache
3:21:53 AM: Finished saving rust rustup cache
3:21:53 AM: Started saving go dependencies
3:21:53 AM: Finished saving go dependencies
3:21:56 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
3:21:56 AM: Creating deploy upload records
3:21:56 AM: Failing build: Failed to build site
3:21:56 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
3:21:56 AM: Finished processing build request in 1m31.986959148s

BUILD SETTINGS:

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

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

Hi @lunaludwig,

I just cloned the starter and was able to deploy it fine, without issues. This error might be due to some custom changes and would suit more on the starter’s GitHub repo. We cannot provide support on code-level unfortunately.

That’s really strange, I couldn’t deploy it before making any changes (An error is thrown if you haven’t updated the siteURL) . Then when I did make changes I only did what was listed in the Read Me file.

A programmer did take a look for me, they believe it isn’t working because my Ghost CMS is local. I thought I’d read others had set this up with locally hosted ghost too but I must have got that wrong.

I appreciate that you’ve tried. I’m going to move on to a different starter file without CMS :slight_smile:

Thanks

I just added SITEURL as an environment variable when connecting the repo to a new website. So, I didn’t have to change it in code. Not sure if that affected it somehow.