I have read through some similar posts regarding the error message “Command failed with exit code 127”. I have read through some docs and added Node and NPM variables into my Netlify environment settings but i am still getting the same error.
Please could someone help?
9:47:23 AM: Netlify Build
9:47:23 AM: ────────────────────────────────────────────────────────────────
9:47:23 AM:
9:47:23 AM: ❯ Version
9:47:23 AM: @netlify/build 29.41.3
9:47:23 AM:
9:47:23 AM: ❯ Flags
9:47:23 AM: baseRelDir: true
9:47:23 AM: buildId: 6645c7f4715a687839cdd058
9:47:23 AM: deployId: 6645c7f4715a687839cdd05a
9:47:23 AM:
9:47:23 AM: ❯ Current directory
9:47:23 AM: /opt/build/repo
9:47:23 AM:
9:47:23 AM: ❯ Config file
9:47:23 AM: No config file was defined: using default values.
9:47:23 AM:
9:47:23 AM: ❯ Context
9:47:23 AM: production
9:47:23 AM:
9:47:23 AM: Build command from Netlify app
9:47:23 AM: ────────────────────────────────────────────────────────────────
9:47:23 AM:
9:47:23 AM: $ next build
9:47:23 AM: bash: next: command not found
9:47:23 AM:
9:47:23 AM: “build.command” failed
9:47:23 AM: ────────────────────────────────────────────────────────────────
9:47:23 AM:
9:47:23 AM: Error message
9:47:23 AM: Command failed with exit code 127: next build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
9:47:23 AM:
9:47:23 AM: Error location
9:47:23 AM: In Build command from Netlify app:
9:47:23 AM: next build
9:47:23 AM:
9:47:23 AM: Resolved config
9:47:23 AM: build:
9:47:23 AM: command: next build
9:47:23 AM: commandOrigin: ui
9:47:23 AM: environment:
9:47:23 AM: - NODE_VERSION
9:47:23 AM: - NPM_VERSION
9:47:23 AM: publish: /opt/build/repo/.next
9:47:23 AM: publishOrigin: ui
9:47:23 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:47:24 AM: Failing build: Failed to build site
9:47:24 AM: Finished processing build request in 16.504s
9:47:24 AM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2 (Search results for '"non-zero exit code: 2"' - Netlify Support Forums)
If everything is correct and still doesn’t work then you may be dealing with Next.js specific junk, since Netlify has additional handling for it, see those docs here: https://docs.netlify.com/frameworks/next-js/overview/
Please could I have a bit more help here. I’m not sure what I should be looking for on these docs. I copied and pasted my package.json code above. You can’t see that?
Here is my latest deploy log. I changed the engines to match what I saw on the Netlify docs I also made a netlify.toml filewith command = “npm run build” and publish =“.net”
10:37:44 AM: Netlify Build
10:37:44 AM: ────────────────────────────────────────────────────────────────
10:37:44 AM:
10:37:44 AM: ❯ Version
10:37:44 AM: @netlify/build 29.41.3
10:37:44 AM:
10:37:44 AM: ❯ Flags
10:37:44 AM: baseRelDir: true
10:37:44 AM: buildId: 6645d3d176c4560007f372a1
10:37:44 AM: deployId: 6645d3d176c4560007f372a3
10:37:44 AM:
10:37:44 AM: ❯ Current directory
10:37:44 AM: /opt/build/repo
10:37:44 AM:
10:37:44 AM: ❯ Config file
10:37:44 AM: No config file was defined: using default values.
10:37:44 AM:
10:37:44 AM: ❯ Context
10:37:44 AM: production
10:37:44 AM:
10:37:44 AM: Build command from Netlify app
10:37:44 AM: ────────────────────────────────────────────────────────────────
10:37:44 AM:
10:37:44 AM: $ next build
10:37:44 AM: bash: next: command not found
10:37:44 AM:
10:37:44 AM: "build.command" failed
10:37:44 AM: ────────────────────────────────────────────────────────────────
10:37:44 AM:
10:37:44 AM: Error message
10:37:44 AM: Command failed with exit code 127: next build (https://ntl.fyi/exit-code-127)
10:37:44 AM:
10:37:44 AM: Error location
10:37:44 AM: In Build command from Netlify app:
10:37:44 AM: next build
10:37:44 AM:
10:37:44 AM: Resolved config
10:37:44 AM: build:
10:37:44 AM: command: next build
10:37:44 AM: commandOrigin: ui
10:37:44 AM: publish: /opt/build/repo/.next
10:37:44 AM: publishOrigin: ui
10:37:44 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:37:45 AM: Failing build: Failed to build site
10:37:45 AM: Finished processing build request in 12.152s
10:37:45 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
@melech I can see the code you pasted in this thread but that’s all I can see, I don’t work for Netlify and don’t have any special visibility, I can only see what you show.
The package.json contents tell me that the same thing it tells you, which is that “next”: “^14.2.3”, is specified under dependencies.
I don’t work with Next.js myself and I don’t tend to assist people working with it, since the additional “automatic” functionality hosts have and the middleware or things like SSR add points of failure I don’t have an interest in.
You can try changing your build command to npm run build.
The main thing to understand is that most of the time, under normal “non-framework specific” conditions, Netlify doesn’t look through your repository to try and locate things or auto-determine what to run.
You set where it should navigate to, what it should execute etc.
i figured out what the issue was. I must have accidentally set up my git remote one level higher in my folder structure. Thanks for your help. onto the OTHER errors now