Netlify-Fail: "Command failed with exit code 1: NODE_ENV=production gatsby build"

I’m trying to install the gatsby-starter-ghost package which works fine on my local machine but fails when deploying to netlify.

The error-log in netlify is as follows:

6:47:37 PM: error "gatsby-source-ghost" threw an error while running the sourceNodes lifecycle:
6:47:37 PM: Cannot read property 'status' of undefined
6:47:37 PM:   105 | 
6:47:37 PM:   106 |     const ignoreNotFoundElseRethrow = (err) => {
6:47:37 PM: > 107 |         if (err.response.status !== 404) {
6:47:37 PM:       |                          ^
6:47:37 PM:   108 |             throw err;
6:47:37 PM:   109 |         }
6:47:37 PM:   110 |     };
6:47:37 PM: 
6:47:37 PM: 
6:47:37 PM:   TypeError: Cannot read property 'status' of undefined
6:47:37 PM:   
6:47:37 PM:   - gatsby-node.js:107 ignoreNotFoundElseRethrow
6:47:37 PM:     [repo]/[gatsby-source-ghost]/gatsby-node.js:107:26
6:47:37 PM:   
6:47:37 PM:   - task_queues.js:97 processTicksAndRejections
6:47:37 PM:     internal/process/task_queues.js:97:5
6:47:37 PM:   
6:47:37 PM: 
6:47:37 PM: not finished source and transform nodes - 0.199s
6:47:37 PM: ​
6:47:37 PM: ┌─────────────────────────────┐
6:47:37 PM: │   "build.command" failed    │
6:47:37 PM: └─────────────────────────────┘
6:47:37 PM: ​
6:47:37 PM:   Error message
6:47:37 PM:   Command failed with exit code 1: NODE_ENV=production gatsby build
6:47:37 PM: ​
6:47:37 PM:   Error location
6:47:37 PM:   In build.command from netlify.toml:
6:47:37 PM:   NODE_ENV=production gatsby build
6:47:37 PM: ​
6:47:37 PM:   Resolved config
6:47:37 PM:   build:
6:47:37 PM:     command: NODE_ENV=production gatsby build
6:47:37 PM:     commandOrigin: config
6:47:37 PM:     publish: /opt/build/repo/public
6:47:37 PM: Caching artifacts
6:47:37 PM: Started saving node modules
6:47:37 PM: Finished saving node modules
6:47:37 PM: Started saving build plugins
6:47:37 PM: Finished saving build plugins
6:47:37 PM: Started saving pip cache
6:47:37 PM: Finished saving pip cache
6:47:37 PM: Started saving emacs cask dependencies
6:47:37 PM: Finished saving emacs cask dependencies
6:47:37 PM: Started saving maven dependencies
6:47:37 PM: Finished saving maven dependencies
6:47:37 PM: Started saving boot dependencies
6:47:37 PM: Finished saving boot dependencies
6:47:37 PM: Started saving go dependencies
6:47:37 PM: Finished saving go dependencies
6:47:41 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
6:47:41 PM: Failing build: Failed to build site
6:47:41 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
6:47:41 PM: Finished processing build request in 1m6.723797109s

Netlify.toml:

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

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

ghost.json:

{
  "development": {
    "apiUrl": "http://localhost:2371",
    "contentApiKey": "34f7e3a488b67c1871a036c666"
  },
  "production": {
    "apiUrl": "http://localhost:2371",
    "contentApiKey": "34f7e3a488b67c1871a036c666"
  }
}

utils/siteConfig.js:

module.exports = {
    siteUrl: `http://0815pascal.netlify.app`, // Site domain. Do not include a trailing slash!

    postsPerPage: 12, // Number of posts shown on paginated pages (changes this requires sometimes to delete the cache)

    siteTitleMeta: `Ghost Gatsby Starter`, // This allows an alternative site title for meta data for pages.
    siteDescriptionMeta: `A starter template to build amazing static websites with Ghost and Gatsby`, // This allows an alternative site description for meta data for pages.

    shareImageWidth: 1000, // Change to the width of your default share image
    shareImageHeight: 523, // Change to the height of your default share image

    shortTitle: `Ghost`, // Used for App manifest e.g. Mobile Home Screen
    siteIcon: `favicon.png`, // Logo in /static dir used for SEO, RSS, and App manifest
    backgroundColor: `#e9e9e9`, // Used for Offline Manifest
    themeColor: `#15171A`, // Used for Offline Manifest
}

I’m running:
node v12.8.3
Ghost-CLI v.1.14.1
npm v6.14.8
Gatsby CLI v.2.12.106
Gatsby v.2.24.67

I also tried it by deleting yarn.lock since this has worked for someone but to no avail.

This URL won’t be accessible by netlify, if you want to use Ghost (either headless or not), you’ll need to have hosting for it set up somewhere - that can be Ghost (Pro), a VPS like Digital Ocean, DDNS, etc.

That makes sense, thank you!