Hello.
When building my application I faced an error: enoent could not read package.json: Error: ENOENT: no such file or directory, open “/opt/build/repo/package.json”.
Netlify site name: https://superlative-unicorn-84c164.netlify.app/ (Site has not yet been deployed)
Build log:
12:16:23 PM: Netlify Build
12:16:23 PM: ────────────────────────────────────────────────────────────────
12:16:23 PM:
12:16:23 PM: ❯ Version
12:16:23 PM: @netlify/build 29.33.2
12:16:23 PM:
12:16:23 PM: ❯ Flags
12:16:23 PM: baseRelDir: true
12:16:23 PM: buildId: 65c06f0ed0b1bfeb0b45a1f8
12:16:23 PM: deployId: 65c06f0ed0b1bfeb0b45a1fa
12:16:23 PM:
12:16:23 PM: ❯ Current directory
12:16:23 PM: /opt/build/repo
12:16:23 PM:
12:16:23 PM: ❯ Config file
12:16:23 PM: No config file was defined: using default values.
12:16:23 PM:
12:16:23 PM: ❯ Context
12:16:23 PM: production
12:16:23 PM:
12:16:23 PM: Build command from Netlify app
12:16:23 PM: ────────────────────────────────────────────────────────────────
12:16:23 PM:
12:16:23 PM: $ npm run build
12:16:23 PM: npm ERR! code ENOENT
12:16:23 PM: npm ERR! syscall open
12:16:23 PM: npm ERR! path /opt/build/repo/package.json
12:16:23 PM: npm ERR! errno -2
12:16:23 PM: npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open "/opt/build/repo/package.json"
12:16:23 PM: npm ERR! enoent This is related to npm not being able to find a file.
12:16:23 PM: npm ERR! enoent
12:16:23 PM: npm ERR! A complete log of this run can be found in: /opt/buildhome/.npm/_logs/2024-02-05T05_16_23_890Z-debug-0.log
12:16:23 PM:
12:16:23 PM: "build.command" failed
12:16:23 PM: ────────────────────────────────────────────────────────────────
12:16:23 PM:
12:16:23 PM: Error message
12:16:23 PM: Command failed with exit code 254: npm run build (https://ntl.fyi/exit-code-254)
12:16:23 PM:
12:16:23 PM: Error location
12:16:23 PM: In Build command from Netlify app:
12:16:23 PM: npm run build
12:16:23 PM:
12:16:23 PM: Resolved config
12:16:23 PM: build:
12:16:23 PM: command: npm run build
12:16:23 PM: commandOrigin: ui
12:16:23 PM: publish: /opt/build/repo/build
12:16:23 PM: publishOrigin: ui
12:16:24 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:16:24 PM: Failing build: Failed to build site
12:16:24 PM: Finished processing build request in 9.894s
12:16:24 PM: Failed during stage "building site": Build script returned non-zero exit code: 2