Netlify not building

Hello! I can’t figure out why build on netlify not working.

Here is deploy logs:

11:35:43 PM:   "build.command" failed                                        
11:35:43 PM: ────────────────────────────────────────────────────────────────
11:35:43 PM: ​
11:35:43 PM:   Error message
11:35:43 PM:   Command failed with exit code 1: CI= npm run build (https://ntl.fyi/exit-code-1)
11:35:43 PM: ​
11:35:43 PM:   Error location
11:35:43 PM:   In Build command from Netlify app:
11:35:43 PM:   CI= npm run build
11:35:43 PM: ​
11:35:43 PM:   Resolved config
11:35:43 PM:   build:
11:35:43 PM:     command: CI= npm run build
11:35:43 PM:     commandOrigin: ui
11:35:43 PM:     environment:
11:35:43 PM:       - NEXT_PRIVATE_TARGET
11:35:43 PM:     publish: /opt/build/repo/build
11:35:43 PM:     publishOrigin: ui
11:35:43 PM:   plugins:
11:35:43 PM:     - inputs: {}
11:35:43 PM:       origin: ui
11:35:43 PM:       package: '@netlify/plugin-nextjs'
11:35:43 PM: Caching artifacts
11:35:43 PM: Started saving node modules
11:35:43 PM: Finished saving node modules
11:35:43 PM: Started saving build plugins
11:35:43 PM: Finished saving build plugins
11:35:43 PM: Started saving yarn cache
11:35:46 PM: Finished saving yarn cache
11:35:46 PM: Started saving pip cache
11:35:46 PM: Finished saving pip cache
11:35:46 PM: Started saving emacs cask dependencies
11:35:46 PM: Finished saving emacs cask dependencies
11:35:46 PM: Started saving maven dependencies
11:35:46 PM: Finished saving maven dependencies
11:35:46 PM: Started saving boot dependencies
11:35:46 PM: Finished saving boot dependencies
11:35:46 PM: Started saving rust rustup cache
11:35:46 PM: Finished saving rust rustup cache
11:35:46 PM: Started saving go dependencies
11:35:46 PM: Finished saving go dependencies
11:35:47 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:35:47 PM: Creating deploy upload records
11:35:47 PM: Failing build: Failed to build site
11:35:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:35:47 PM: Finished processing build request in 1m48.838514126s

My package.json file:

"name": "my-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "rm -rf graph-data.json && next dev",
     "build": "rm -rf graph-data.json && next build",
    "start": "next start",
    "deploy": "yarn build && git add . && git commit -m '...' && git push"

@SuperPuper123 Are you able to show the full build log?

Hi @SuperPuper123

I believe the issue that is the root of the problem is a few lines above what you pasted. Did you notice this?

11:34:54 AM: Error: ENOENT: no such file or directory, lstat '/opt/build/repo/graph-data.json'
11:34:54 AM:     at Object.lstatSync (node:fs:1561:3)
11:34:54 AM:     at Object.isFile (/opt/build/repo/.next/server/chunks/403.js:264:62)
11:34:54 AM:     at constructGraphData (/opt/build/repo/.next/server/chunks/403.js:751:65)
11:34:54 AM:     at /opt/build/repo/.next/server/pages/note/[id].js:95:100 {
11:34:54 AM:   errno: -2,
11:34:54 AM:   syscall: 'lstat',
11:34:54 AM:   code: 'ENOENT',
11:34:54 AM:   path: '/opt/build/repo/graph-data.json'
11:34:54 AM: }
11:34:54 AM: Error: ENOENT: no such file or directory, lstat '/opt/build/repo/graph-data.json'
11:34:54 AM:     at Object.lstatSync (node:fs:1561:3)
11:34:54 AM:     at Object.isFile (/opt/build/repo/.next/server/chunks/403.js:264:62)
11:34:54 AM:     at constructGraphData (/opt/build/repo/.next/server/chunks/403.js:751:65)
11:34:54 AM:     at /opt/build/repo/.next/server/pages/index.js:69:100 {
11:34:54 AM:   errno: -2,
11:34:54 AM:   syscall: 'lstat',
11:34:54 AM:   code: 'ENOENT',
11:34:54 AM:   path: '/opt/build/repo/graph-data.json'
11:34:54 AM: }
11:34:56 AM: info  - Generating static pages (0/106)
11:35:10 AM: ERRROR:Error: Unknown language: `yaml:dbfolder` is not registered
11:35:21 AM: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
11:35:21 AM: Error: ENOENT: no such file or directory, open '/opt/build/repo/posts/index.md'
11:35:21 AM:     at Object.openSync (node:fs:590:3)
11:35:21 AM:     at Object.readFileSync (node:fs:458:35)
11:35:21 AM:     at Object.readFileSync (/opt/build/repo/.next/server/chunks/403.js:290:58)
11:35:21 AM:     at getSinglePost (/opt/build/repo/.next/server/chunks/403.js:704:85)
11:35:21 AM:     at getStaticProps (/opt/build/repo/.next/server/pages/index.js:72:92)
11:35:21 AM:     at renderToHTML (/opt/build/repo/node_modules/next/dist/server/render.js:465:26)
11:35:21 AM:     at async /opt/build/repo/node_modules/next/dist/export/worker.js:269:36
11:35:21 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:35:23 AM: info  - Generating static pages (26/106)
11:35:31 AM: info  - Generating static pages (52/106)
11:35:41 AM: info  - Generating static pages (79/106)
11:35:43 AM: info  - Generating static pages (106/106)
11:35:43 AM: > Build error occurred
11:35:43 AM: Error: Export encountered errors on following paths:
11:35:43 AM: 	/
11:35:43 AM:     at /opt/build/repo/node_modules/next/dist/export/index.js:498:19
11:35:43 AM:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
11:35:43 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:35:43 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:1024:17
11:35:43 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:35:43 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:898:13
11:35:43 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:75:20)
11:35:43 AM:     at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:82:25)

Perhaps this will help: npm - How to resolve Node.js: "Error: ENOENT: no such file or directory" - Stack Overflow

Thanks, I didn’t see this. But now I can’t found the right path? Or I need to delete from all files this path?
Can yo help me with that?

My github:

According to the error, your repo is missing a file named graph-data.json in the root of the repo. Now, we don’t know what that file is, or what it’s supposed to do, or why it’s missing. But adding the file there would be the first step, I assume.