Site name: https://qingstocksite.netlify.app/
Build Log:
1:56:12 PM: Netlify Build
1:56:12 PM: ────────────────────────────────────────────────────────────────
1:56:12 PM:
1:56:12 PM: ❯ Version
1:56:12 PM: @netlify/build 29.58.8
1:56:12 PM:
1:56:12 PM: ❯ Flags
1:56:12 PM: accountId: 675aec3452383665178e485a
1:56:12 PM: baseRelDir: true
1:56:12 PM: buildId: 67a2fd54d5110cdb7de89a5b
1:56:12 PM: deployId: 67a2fd54d5110cdb7de89a5d
1:56:12 PM:
1:56:12 PM: ❯ Current directory
1:56:12 PM: /opt/build/repo
1:56:12 PM:
1:56:12 PM: ❯ Config file
1:56:12 PM: /opt/build/repo/netlify.toml
1:56:12 PM:
1:56:12 PM: ❯ Context
1:56:12 PM: production
1:56:12 PM:
1:56:12 PM: ❯ Using Next.js Runtime - v5.9.4
1:56:14 PM: No Next.js cache to restore
1:56:14 PM:
1:56:14 PM: build.command from netlify.toml
1:56:14 PM: ────────────────────────────────────────────────────────────────
1:56:14 PM:
1:56:14 PM: $ npm run build
1:56:14 PM: > stock-management-app@1.0.0 build
1:56:14 PM: > next build
1:56:14 PM: No build cache found. Please configure build caching for faster rebuilds. Read more: No Cache Detected | Next.js
1:56:14 PM: ▲ Next.js 15.1.6
1:56:14 PM: Linting and checking validity of types …
1:56:15 PM: Creating an optimized production build …
1:56:23 PM: ✓ Compiled successfully
1:56:23 PM: Collecting page data …
1:56:27 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:56:27 PM: Here’s the url we are trying to fetch from: https://qingstocksite.netlify.app/.netlify/functions/orders
Here’s the url we are trying to fetch from: https://qingstocksite.netlify.app/.netlify/functions/orders
Failed to retrieve orders from orderDB during build time
1:56:27 PM: SyntaxError: Unexpected token N in JSON at position 0
1:56:27 PM: at JSON.parse ()
1:56:27 PM: at async n (.next/server/pages/admin/orders/[id].js:1:2708)
1:56:27 PM: [Error: Invalid value returned from getStaticPaths in /admin/orders/[id]. Received undefined Expected: { paths: , fallback: boolean }
1:56:27 PM: See here for more info: Invalid `getStaticPaths` Return Value | Next.js]
1:56:27 PM: > Build error occurred
1:56:27 PM: [Error: Failed to collect page data for /admin/orders/[id]] {
1:56:27 PM: type: ‘Error’
1:56:27 PM: }
1:56:27 PM:
1:56:27 PM: “build.command” failed
1:56:27 PM: ────────────────────────────────────────────────────────────────
1:56:27 PM:
1:56:27 PM: Error message
1:56:27 PM: Command failed with exit code 1: npm run build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
1:56:27 PM:
1:56:27 PM: Error location
1:56:27 PM: In build.command from netlify.toml:
1:56:27 PM: npm run build
1:56:27 PM:
1:56:27 PM: Resolved config
1:56:27 PM: build:
1:56:27 PM: command: npm run build
1:56:27 PM: commandOrigin: config
1:56:27 PM: environment:
1:56:27 PM: - NEXT_PUBLIC_ROOT_PAGE
1:56:27 PM: publish: /opt/build/repo/.next
1:56:27 PM: publishOrigin: config
1:56:27 PM: functionsDirectory: /opt/build/repo/netlify/functions
1:56:27 PM: plugins:
1:56:27 PM: - inputs: {}
1:56:27 PM: origin: ui
1:56:27 PM: package: ‘@netlify/plugin-nextjs’
1:56:27 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:56:27 PM: Failing build: Failed to build site
1:56:28 PM: Finished processing build request in 45.513s
build settings:
running a local development server works fine. The issue is during deployment, my fetch request seems like it isnt getting the correct data thus causing .json() to throw an error when trying to parse the data into a JS object. I believe “https://qingstocksite.netlify.app/.netlify/functions/orders” is the correct URL for the deployed serverless function but when i navigate to the functions tab in my netlify deployment settings, i do not see any deployed functions. Isn’t netlify suppose to handle this for me? I’m not too sure what to do. I don’t see anything wrong with my directory structure - the serverless functions are not nested. Any help would be appreciated.