Build Error ng build or npm run build not recognized

I am getting this error. Kindly help: 5:13:56 PM: Netlify Build
5:13:56 PM: ────────────────────────────────────────────────────────────────
5:13:56 PM: ​
5:13:56 PM: ❯ Version
5:13:56 PM: @netlify/build 29.27.0
5:13:56 PM: ​
5:13:56 PM: ❯ Flags
5:13:56 PM: baseRelDir: true
5:13:56 PM: buildId: 655d479e6e852327d041eb0a
5:13:56 PM: deployId: 655d479e6e852327d041eb0c
5:13:56 PM: ​
5:13:56 PM: ❯ Current directory
5:13:56 PM: /opt/build/repo
5:13:56 PM: ​
5:13:56 PM: ❯ Config file
5:13:56 PM: No config file was defined: using default values.
5:13:56 PM: ​
5:13:56 PM: ❯ Context
5:13:56 PM: production
5:13:56 PM: ​
5:13:56 PM: Build command from Netlify app
5:13:56 PM: ────────────────────────────────────────────────────────────────
5:13:56 PM: ​
5:13:56 PM: $ npm run build
5:13:57 PM: Failed during stage “building site”: Build script returned non-zero exit code: 2
5:13:56 PM: npm ERR! code ENOENT
5:13:56 PM: npm ERR! syscall open
5:13:56 PM: npm ERR! path /opt/build/repo/package.json
5:13:56 PM: npm ERR! errno -2
5:13:56 PM: npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open “/opt/build/repo/package.json”
5:13:56 PM: npm ERR! enoent This is related to npm not being able to find a file.
5:13:56 PM: npm ERR! enoent
5:13:56 PM: npm ERR! A complete log of this run can be found in: /opt/buildhome/.npm/_logs/2023-11-22T00_13_56_520Z-debug-0.log
5:13:56 PM: ​
5:13:56 PM: “build.command” failed
5:13:56 PM: ────────────────────────────────────────────────────────────────
5:13:56 PM: ​
5:13:56 PM: Error message
5:13:56 PM: Command failed with exit code 254: npm run build (Search results for '"non-zero exit code: 254"' - Netlify Support Forums)
5:13:56 PM: ​
5:13:56 PM: Error location
5:13:56 PM: In Build command from Netlify app:
5:13:56 PM: npm run build
5:13:56 PM: ​
5:13:56 PM: Resolved config
5:13:56 PM: build:
5:13:56 PM: command: npm run build
5:13:56 PM: commandOrigin: ui
5:13:56 PM: publish: /opt/build/repo
5:13:56 PM: publishOrigin: ui
5:13:57 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:13:57 PM: Failing build: Failed to build site
5:13:57 PM: Finished processing build request in 10.218s

There’s no package.json in your repo.

Hello, I successfully corrected the error but now there is an issue with connecting to my backend. I have changed the base URL to my render.com link but it still wont connect. What could be the issue?

can you share the recent failed deploy?

Hello Sam.

I managed to correct the issue. Thank you for uour patience and help.

Chebet.

1 Like

great! glad to hear it.