Build failed due to a user error: Build script returned non-zero exit code: 2

1:33:40 PM: ────────────────────────────────────────────────────────────────
1:33:40 PM: 1. @netlify/plugin-nextjs (onPreBuild event)
1:33:40 PM: ────────────────────────────────────────────────────────────────
1:33:40 PM: ​
1:33:40 PM: No Next.js cache to restore.
1:33:40 PM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
1:33:40 PM: ​
1:33:40 PM: (@netlify/plugin-nextjs onPreBuild completed in 26ms)
1:33:40 PM: ​
1:33:40 PM: ────────────────────────────────────────────────────────────────
1:33:40 PM: 2. Build command from Netlify app
1:33:40 PM: ────────────────────────────────────────────────────────────────
1:33:40 PM: ​
1:33:40 PM: $ CI= npm run build
1:33:40 PM: > graphcms-blog@0.1.0 build
1:33:40 PM: > next build
1:33:41 PM: info - Using webpack 5. Reason: Enabled by default webpack5 | Next.js
1:33:41 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: no-cache | Next.js
1:33:41 PM: info - Checking validity of types…
1:33:43 PM: error - ESLint: .eslintrc.js: Configuration for rule “max-len” is invalid: Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed ‘5’).
1:33:43 PM: info - Creating an optimized production build…
1:34:08 PM: info - Compiled successfully
1:34:08 PM: info - Collecting page data…
1:34:08 PM: > Build error occurred
1:34:08 PM: TypeError: Only absolute URLs are supported
1:34:08 PM: at getNodeRequestOptions (/opt/build/repo/node_modules/node-fetch/lib/index.js:1327:9)
1:34:08 PM: at /opt/build/repo/node_modules/node-fetch/lib/index.js:1440:19
1:34:08 PM: at new Promise ()
1:34:08 PM: at fetch (/opt/build/repo/node_modules/node-fetch/lib/index.js:1437:9)
1:34:08 PM: at fetch (/opt/build/repo/node_modules/cross-fetch/dist/node-ponyfill.js:10:20)
1:34:08 PM: at /opt/build/repo/node_modules/graphql-request/dist/index.js:163:42
1:34:08 PM: at step (/opt/build/repo/node_modules/graphql-request/dist/index.js:63:23)
1:34:08 PM: at Object.next (/opt/build/repo/node_modules/graphql-request/dist/index.js:44:53)
1:34:08 PM: at /opt/build/repo/node_modules/graphql-request/dist/index.js:38:71
1:34:08 PM: at new Promise () {
1:34:08 PM: type: ‘TypeError’
1:34:08 PM: }
1:34:09 PM: ​
1:34:09 PM: ────────────────────────────────────────────────────────────────
1:34:09 PM: “build.command” failed
1:34:09 PM: ────────────────────────────────────────────────────────────────
1:34:09 PM: ​
1:34:09 PM: Error message
1:34:09 PM: Command failed with exit code 1: CI= npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:34:09 PM: ​
1:34:09 PM: Error location
1:34:09 PM: In Build command from Netlify app:
1:34:09 PM: CI= npm run build
1:34:09 PM: ​
1:34:09 PM: Resolved config
1:34:09 PM: build:
1:34:09 PM: command: CI= npm run build
1:34:09 PM: commandOrigin: ui
1:34:09 PM: environment:
1:34:09 PM: - NEXT_PRIVATE_TARGET
1:34:09 PM: publish: /opt/build/repo/.next
1:34:09 PM: publishOrigin: ui
1:34:09 PM: plugins:
1:34:09 PM: - inputs: {}
1:34:09 PM: origin: ui
1:34:09 PM: package: ‘@netlify/plugin-nextjs’
1:34:09 PM: Caching artifacts
1:34:09 PM: Started saving node modules
1:34:09 PM: Finished saving node modules
1:34:09 PM: Started saving build plugins
1:34:09 PM: Finished saving build plugins
1:34:09 PM: Started saving yarn cache
1:34:11 PM: Finished saving yarn cache
1:34:11 PM: Started saving pip cache
1:34:11 PM: Finished saving pip cache
1:34:11 PM: Started saving emacs cask dependencies
1:34:11 PM: Finished saving emacs cask dependencies
1:34:11 PM: Started saving maven dependencies
1:34:11 PM: Finished saving maven dependencies
1:34:11 PM: Started saving boot dependencies
1:34:11 PM: Finished saving boot dependencies
1:34:11 PM: Started saving rust rustup cache
1:34:11 PM: Finished saving rust rustup cache
1:34:11 PM: Started saving go dependencies
1:34:11 PM: Finished saving go dependencies
1:34:13 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:34:13 PM: Creating deploy upload records
1:34:13 PM: Failing build: Failed to build site
1:34:13 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
1:34:13 PM: Finished processing build request in 1m28.368693887s

Hi @iilhamriz,

That appears to be the source of the error. You’re not using absolute URLs in your code where it seem to be required.