Failed during stage 'building site': GraphQL Error

brilliant-squirrel-24a999

I’m using the Gatsby starter template for Netlify-CMS. I’m trying to add Disqus comments to my blog-post.js page. It keeps failing.

error preview:
10:36:58 AM: error There was a problem parsing “/opt/build/repo/src/templates/blog-post.js”; any GraphQL fragments or queries in this file were not processed. This may indicate a syntax error in the code, or it may be a file type that Gatsby does not know how to parse.

10:36:58 AM: failed extract queries from components - 5.671s

Full Build log:

10:36:20 AM: build-image version: a2d22d22e4555d1ef0a972ed14a0a4b366ad20c4 (focal)
10:36:20 AM: build-image tag: v4.16.3
10:36:20 AM: buildbot version: 0d92ba804851e1768a79721ec5ad312cd15c4ac9
10:36:21 AM: Fetching cached dependencies
10:36:21 AM: Starting to download cache of 262.7MB
10:36:23 AM: Finished downloading cache in 2.331100949s
10:36:23 AM: Starting to extract cache
10:36:26 AM: Finished extracting cache in 3.169237899s
10:36:26 AM: Finished fetching cache in 5.541983105s
10:36:26 AM: Starting to prepare the repo for build
10:36:27 AM: Preparing Git Reference refs/heads/main
10:36:28 AM: Parsing package.json dependencies
10:36:29 AM: Starting build script
10:36:29 AM: Installing dependencies
10:36:29 AM: Python version set to 2.7
10:36:29 AM: Started restoring cached Node.js version
10:36:30 AM: Finished restoring cached Node.js version
10:36:30 AM: v14.15.0 is already installed.
10:36:30 AM: Now using node v14.15.0 (npm v6.14.8)
10:36:30 AM: Started restoring cached build plugins
10:36:30 AM: Finished restoring cached build plugins
10:36:30 AM: Attempting Ruby version 2.7.2, read from environment
10:36:31 AM: Using Ruby version 2.7.2
10:36:31 AM: Using PHP version 8.0
10:36:31 AM: Started restoring cached corepack dependencies
10:36:31 AM: mv: cannot move '/opt/build/cache/.node/corepack' to '/opt/buildhome/.node/corepack': No such file or directory
10:36:31 AM: Finished restoring cached corepack dependencies
10:36:31 AM: No npm workspaces detected
10:36:31 AM: Started restoring cached node modules
10:36:31 AM: Finished restoring cached node modules
10:36:31 AM: Bypassing sha validation. Running pre & post install scripts
10:36:31 AM: Installing npm packages using npm version 6.14.8
10:36:40 AM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!npm WARN eslint-config-react-app@6.0.0 requires a peer of babel-eslint@^10.0.0 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN fork-ts-checker-webpack-plugin@6.5.2 requires a peer of typescript@>= 2.7 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825 requires a peer of react@0.0.0-experimental-c8b778b7f-20220825 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN netlify-cms-backend-test@2.11.3 requires a peer of uuid@^3.3.2 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN ajv-keywords@5.1.0 requires a peer of ajv@^8.8.2 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN netlify-cms-lib-auth@2.4.2 requires a peer of uuid@^3.3.2 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN netlify-cms-widget-image@2.8.1 requires a peer of netlify-cms-widget-file@^2.9.2 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN react-codemirror2@7.2.1 requires a peer of react@>=15.5 <=16.x but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN gatsby-plugin-netlify-cms@5.15.0 requires a peer of gatsby@^3.0.0-next.0 but none is installed. You must install peer dependencies yourself.
10:36:40 AM: npm WARN gatsby-starter-netlify-cms@1.1.3 No repository field.
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-arm64@2.5.3 (node_modules/@lmdb/lmdb-darwin-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-arm64@2.5.3: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-x64@2.5.3 (node_modules/@lmdb/lmdb-darwin-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-x64@2.5.3: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm@2.5.3 (node_modules/@lmdb/lmdb-linux-arm):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm@2.5.3: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm64@2.5.3 (node_modules/@lmdb/lmdb-linux-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm64@2.5.3: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-win32-x64@2.5.3 (node_modules/@lmdb/lmdb-win32-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-win32-x64@2.5.3: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-darwin-arm64@2.0.2 (node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-darwin-arm64@2.0.2: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-darwin-x64@2.0.2 (node_modules/@msgpackr-extract/msgpackr-extract-darwin-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-darwin-x64@2.0.2: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-linux-arm@2.0.2 (node_modules/@msgpackr-extract/msgpackr-extract-linux-arm):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-linux-arm@2.0.2: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-linux-arm64@2.0.2 (node_modules/@msgpackr-extract/msgpackr-extract-linux-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-linux-arm64@2.0.2: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @msgpackr-extract/msgpackr-extract-win32-x64@2.0.2 (node_modules/@msgpackr-extract/msgpackr-extract-win32-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @msgpackr-extract/msgpackr-extract-win32-x64@2.0.2: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-arm64@2.5.2 (node_modules/@parcel/cache/node_modules/@lmdb/lmdb-darwin-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-arm64@2.5.2: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-darwin-x64@2.5.2 (node_modules/@parcel/cache/node_modules/@lmdb/lmdb-darwin-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-darwin-x64@2.5.2: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm@2.5.2 (node_modules/@parcel/cache/node_modules/@lmdb/lmdb-linux-arm):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm@2.5.2: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-linux-arm64@2.5.2 (node_modules/@parcel/cache/node_modules/@lmdb/lmdb-linux-arm64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-linux-arm64@2.5.2: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @lmdb/lmdb-win32-x64@2.5.2 (node_modules/@parcel/cache/node_modules/@lmdb/lmdb-win32-x64):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @lmdb/lmdb-win32-x64@2.5.2: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
10:36:40 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:36:40 AM: added 4 packages from 1 contributor, removed 6 packages, updated 5 packages and audited 1978 packages in 8.129s
10:36:40 AM: 331 packages are looking for funding
10:36:40 AM:   run `npm fund` for details
10:36:40 AM: found 15 vulnerabilities (7 moderate, 8 high)
10:36:40 AM:   run `npm audit fix` to fix them, or `npm audit` for details
10:36:40 AM: npm packages installed
10:36:41 AM: Started restoring cached go cache
10:36:41 AM: Finished restoring cached go cache
10:36:41 AM: go version go1.19.4 linux/amd64
10:36:41 AM: Detected 1 framework(s)
10:36:41 AM: "gatsby" at version "4.25.2"
10:36:41 AM: Installing missing commands
10:36:41 AM: Verify run directory
10:36:41 AM: Section completed: initializing
10:36:42 AM: ​
10:36:42 AM:   Netlify Build                                                 
10:36:42 AM: ────────────────────────────────────────────────────────────────
10:36:42 AM: ​
10:36:42 AM: ❯ Version
10:36:42 AM:   @netlify/build 29.4.1
10:36:42 AM: ​
10:36:42 AM: ❯ Flags
10:36:42 AM:   baseRelDir: true
10:36:42 AM:   buildId: 63bd85f394326700081b6d38
10:36:42 AM:   deployId: 63bd85f394326700081b6d3a
10:36:42 AM: ​
10:36:42 AM: ❯ Current directory
10:36:42 AM:   /opt/build/repo
10:36:42 AM: ​
10:36:42 AM: ❯ Config file
10:36:42 AM:   /opt/build/repo/netlify.toml
10:36:42 AM: ​
10:36:42 AM: ❯ Context
10:36:42 AM:   production
10:36:42 AM: ​
10:36:42 AM: ❯ Loading plugins
10:36:42 AM:    - @netlify/plugin-gatsby@3.4.8 from Netlify app
10:36:44 AM: ​
10:36:44 AM:   1. @netlify/plugin-gatsby (onPreBuild event)                  
10:36:44 AM: ────────────────────────────────────────────────────────────────
10:36:44 AM: ​
10:36:44 AM: Found a Gatsby cache. We’re about to go FAST. ⚡️
10:36:44 AM: ​
10:36:44 AM: (@netlify/plugin-gatsby onPreBuild completed in 329ms)
10:36:44 AM: ​
10:36:44 AM:   2. build.command from netlify.toml                            
10:36:44 AM: ────────────────────────────────────────────────────────────────
10:36:44 AM: ​
10:36:44 AM: $ npm run build
10:36:44 AM: > gatsby-starter-netlify-cms@1.1.3 build /opt/build/repo
10:36:44 AM: > npm run clean && gatsby build
10:36:44 AM: > gatsby-starter-netlify-cms@1.1.3 clean /opt/build/repo
10:36:44 AM: > gatsby clean
10:36:45 AM: info Deleting .cache, public, /opt/build/repo/node_modules/.cache/babel-loader, /opt/build/repo/node_modules/.cache/terser-webpack-plugin
10:36:45 AM: info Successfully deleted directories
10:36:47 AM: success compile gatsby files - 0.942s
10:36:47 AM: success load gatsby config - 0.014s
10:36:48 AM: warning Plugin gatsby-plugin-netlify-cms is not compatible with your gatsby version 4.25.2 - It requires gatsby@^3.0.0-next.0
10:36:48 AM: warning Plugin gatsby-plugin-netlify-cms is not compatible with your gatsby version 4.25.2 - It requires gatsby@^3.0.0-next.0
10:36:48 AM: success load plugins - 0.626s
10:36:48 AM: warning gatsby-plugin-react-helmet: Gatsby now has built-in support for modifying the document head. Learn more at https://gatsby.dev/gatsby-head
10:36:48 AM: success onPreInit - 0.004s
10:36:48 AM: success initialize cache - 0.058s
10:36:48 AM: success copy gatsby files - 0.068s
10:36:48 AM: success Compiling Gatsby Functions - 0.134s
10:36:48 AM: success onPreBootstrap - 0.141s
10:36:49 AM: success createSchemaCustomization - 0.006s
10:36:50 AM: success Checking for changed pages - 0.000s
10:36:50 AM: success source and transform nodes - 1.295s
10:36:51 AM: info Writing GraphQL type definitions to /opt/build/repo/.cache/schema.gql
10:36:52 AM: success building schema - 1.498s
10:36:52 AM: success createPages - 0.200s
10:36:52 AM: success createPagesStatefully - 0.702s
10:36:52 AM: info Total nodes: 132, SitePage nodes: 13 (use --verbose for breakdown)
10:36:52 AM: success Checking for changed pages - 0.000s
10:36:52 AM: success onPreExtractQueries - 0.000s
10:36:58 AM: error There was a problem parsing "/opt/build/repo/src/templates/blog-post.js"; any GraphQL
10:36:58 AM: fragments or queries in this file were not processed.
10:36:58 AM: This may indicate a syntax error in the code, or it may be a file type
10:36:58 AM: that Gatsby does not know how to parse.
10:36:58 AM: failed extract queries from components - 5.671s
10:36:58 AM: npm ERR! code ELIFECYCLE
10:36:58 AM: npm ERR! errno 1
10:36:58 AM: npm ERR! gatsby-starter-netlify-cms@1.1.3 build: `npm run clean && gatsby build`
10:36:58 AM: npm ERR! Exit status 1
10:36:58 AM: npm ERR!
10:36:58 AM: npm ERR! Failed at the gatsby-starter-netlify-cms@1.1.3 build script.
10:36:58 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:36:58 AM: npm ERR! A complete log of this run can be found in:
10:36:58 AM: npm ERR!     /opt/buildhome/.npm/_logs/2023-01-10T15_36_58_629Z-debug.log
10:36:58 AM: ​
10:36:58 AM:   "build.command" failed                                        
10:36:58 AM: ────────────────────────────────────────────────────────────────
10:36:58 AM: ​
10:36:58 AM:   Error message
10:36:59 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:36:58 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
10:36:58 AM: ​
10:36:58 AM:   Error location
10:36:58 AM:   In build.command from netlify.toml:
10:36:58 AM:   npm run build
10:36:58 AM: ​
10:36:58 AM:   Resolved config
10:36:58 AM:   build:
10:36:58 AM:     command: npm run build
10:36:58 AM:     commandOrigin: config
10:36:58 AM:     environment:
10:36:58 AM:       - NODE_VERSION
10:36:58 AM:       - YARN_VERSION
10:36:58 AM:       - YARN_FLAGS
10:36:58 AM:     publish: /opt/build/repo/public
10:36:58 AM:     publishOrigin: config
10:36:58 AM:   functionsDirectory: /opt/build/repo/netlify/functions
10:36:58 AM:   headers:
10:36:59 AM:     - for: /*      values:        Referrer-Policy: same-origin        X-Content-Type-Options: nosniff        X-Frame-Options: DENY        X-XSS-Protection: 1; mode=block    - for: /styles.279f857e4dfbf09a87b1.css      values:        Cache-Control: public, max-age=31536000, immutable    - for: /commons-9763bec27d1f25223772.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-templates-about-page-js-fb0877fb5d4862169bd0.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-templates-blog-post-js-90b63bcfebc3d871a40d.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /6856248c00fc7a17368c03e2cf9f4280bd8891ff-af379ea2a76260881bca.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-templates-index-page-js-2f37870e407c136eb6d6.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-templates-product-page-js-0f36e22deab628e1d4e6.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-templates-tags-js-916dfbe8e089c65cdb38.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-404-js-ce71c2dcb62a8ed89b08.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-blog-index-js-a9e8b4bddf996d71882e.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-contact-examples-js-f4906c02806d814af6df.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-contact-file-upload-js-786080573f62bce7759a.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-contact-index-js-92dc8b3eb1253672e97e.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-contact-thanks-js-6945f1da4b0dc2796a98.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /component---src-pages-tags-index-js-a63c59b1d31a9621175e.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /webpack-runtime-a96dfcc741bccbf9e0c1.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /framework-87d9c2596f6db97ad266.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /532a2f07-f97befafd74bf8dd0311.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /app-8009a75081ca83cc3ce8.js      values:        Cache-Control: public, max-age=31536000, immutable    - for: /static/*      values:        Cache-Control: public, max-age=31536000, immutable    - for: /sw.js      values:        Cache-Control: no-cache  plugins:    - inputs: {}      origin: ui      package: '@netlify/plugin-gatsby'Caching artifacts
10:36:59 AM: Started saving node modules
10:36:59 AM: Finished saving node modules
10:36:59 AM: Started saving build plugins
10:36:59 AM: Finished saving build plugins
10:36:59 AM: Started saving pip cache
10:36:59 AM: Finished saving pip cache
10:36:59 AM: Started saving emacs cask dependencies
10:36:59 AM: Finished saving emacs cask dependencies
10:36:59 AM: Started saving maven dependencies
10:36:59 AM: Finished saving maven dependencies
10:36:59 AM: Started saving boot dependencies
10:36:59 AM: Finished saving boot dependencies
10:36:59 AM: Started saving rust rustup cache
10:36:59 AM: Finished saving rust rustup cache
10:36:59 AM: Started saving go dependencies
10:36:59 AM: Finished saving go dependencies
10:36:59 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:36:59 AM: Failing build: Failed to build site
10:36:59 AM: Finished processing build request in 38.443918525s

Hiya @thecopelandcollectiv and welcome!

Can I confirm that you are using this template?

There have been a variety of templates matching your description over the years, many of which we’d expect to fail now, years after they were created and not maintained.

If that is the one you are using, great! That should be the best maintained one. If you aren’t using it, I’d suggest starting over with that one.

Next up is how to debug builds: [Support Guide] Debugging Netlify site builds

While I don’t want you to debug our template, the error message is pretty clearly about a file I presume you created or modified, right? That blog post? What I’d love you to debug is just “can you build this locally, and if not, can you troubleshoot based on that file in your local build, what the error message might be talking about?” and that article describes a lot more details about how to do that :slight_smile:

Let me know how it goes!

Yes I am using the latest. For some reason it won’t build locally. it goes through the whole build script and looks good until the end where I get a zsh: command not found error and nothing happens.

which command is not found? Could you share the entire log?