Error in Deploying Website

Hi there, I have been having trouble deploying my website. It appears that the file in the github branch has been updated, but the updates are not reflected on the website realtime. Here is the error log I got from the system:

11:50:15 PM: error Command failed with exit code 1. (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:50:15 PM: info Visit yarn run | Yarn for documentation about this command.
11:50:15 PM: ​
11:50:15 PM: ────────────────────────────────────────────────────────────────
11:50:15 PM: “build.command” failed
11:50:15 PM: ────────────────────────────────────────────────────────────────
11:50:15 PM: ​
11:50:15 PM: Error message
11:50:15 PM: Command failed with exit code 1: yarn build (Search results for '"non-zero exit code: 1"' - Netlify Support Forums)
11:50:15 PM: ​
11:50:15 PM: Error location
11:50:15 PM: In Build command from Netlify app:
11:50:15 PM: yarn build
11:50:15 PM: ​
11:50:15 PM: Resolved config
11:50:15 PM: build:
11:50:15 PM: command: yarn build
11:50:15 PM: commandOrigin: ui
11:50:15 PM: environment:
11:50:15 PM: - NEXT_PRIVATE_TARGET
11:50:15 PM: publish: /opt/build/repo/.next
11:50:15 PM: publishOrigin: ui
11:50:15 PM: plugins:
11:50:15 PM: - inputs: {}
11:50:15 PM: origin: ui
11:50:15 PM: package: ‘@netlify/plugin-nextjs’

Would appreciate if someone can point out the parts that I need to change. Thanks!

Hi @juanmarkus

Unfortunately you have omitted the portion of the deploy log that outlines why the build failed. Can you please share the entire log (or the URL for it) and also the repository you are deploying from.

Hi, thanks for responding. Since new users are restricted in what we can share, I’ll do my best to share the larger portion of the log down below.

12:35:04 AM: ────────────────────────────────────────────────────────────────
12:35:04 AM: Netlify Build
12:35:04 AM: ────────────────────────────────────────────────────────────────
12:35:04 AM: ​
12:35:04 AM: ❯ Version
12:35:04 AM: @netlify/build 27.20.6
12:35:04 AM: ​
12:35:04 AM: ❯ Flags
12:35:04 AM: baseRelDir: true
12:35:04 AM: buildId: 63498168d774680009e7286a
12:35:04 AM: deployId: 63498168d774680009e7286c
12:35:04 AM: ​
12:35:04 AM: ❯ Current directory
12:35:04 AM: /opt/build/repo
12:35:04 AM: ​
12:35:04 AM: ❯ Config file
12:35:04 AM: No config file was defined: using default values.
12:35:04 AM: ​
12:35:04 AM: ❯ Context
12:35:04 AM: production
12:35:05 AM: ​
12:35:05 AM: ❯ Using Next.js Runtime - v4.25.0
12:35:06 AM: ​
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: 1. @netlify/plugin-nextjs (onPreBuild event)
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: ​
12:35:06 AM: No Next.js cache to restore.
12:35:06 AM: Netlify configuration property “build.environment.NEXT_PRIVATE_TARGET” value changed.
12:35:06 AM: ​
12:35:06 AM: (@netlify/plugin-nextjs onPreBuild completed in 14ms)
12:35:06 AM: ​
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: 2. Build command from Netlify app
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: ​
12:35:06 AM: $ yarn build
12:35:06 AM: yarn run v1.22.19
12:35:06 AM: $ CI = npm run build
12:35:06 AM: /bin/sh: 1: CI: not found
12:35:06 AM: error Command failed with exit code 127. (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
12:35:06 AM: info Visit yarn run | Yarn for documentation about this command.
12:35:06 AM: ​
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: “build.command” failed
12:35:06 AM: ────────────────────────────────────────────────────────────────
12:35:06 AM: ​
12:35:06 AM: Error message
12:35:06 AM: Command failed with exit code 127: yarn build (Search results for '"non-zero exit code: 127"' - Netlify Support Forums)
12:35:06 AM: ​
12:35:06 AM: Error location
12:35:06 AM: In Build command from Netlify app:
12:35:06 AM: yarn build
12:35:06 AM: ​
12:35:06 AM: Resolved config
12:35:06 AM: build:
12:35:06 AM: command: yarn build
12:35:06 AM: commandOrigin: ui
12:35:06 AM: environment:
12:35:06 AM: - NEXT_PRIVATE_TARGET
12:35:06 AM: publish: /opt/build/repo/.next
12:35:06 AM: publishOrigin: ui
12:35:06 AM: plugins:
12:35:06 AM: - inputs: {}
12:35:06 AM: origin: ui
12:35:06 AM: package: ‘@netlify/plugin-nextjs’
12:35:06 AM: Caching artifacts
12:35:06 AM: Started saving node modules
12:35:06 AM: Finished saving node modules
12:35:06 AM: Started saving build plugins
12:35:06 AM: Finished saving build plugins
12:35:06 AM: Started saving yarn cache
12:35:11 AM: Finished saving yarn cache
12:35:11 AM: Started saving pip cache
12:35:11 AM: Finished saving pip cache
12:35:11 AM: Started saving emacs cask dependencies
12:35:11 AM: Finished saving emacs cask dependencies
12:35:11 AM: Started saving maven dependencies
12:35:11 AM: Finished saving maven dependencies
12:35:11 AM: Started saving boot dependencies
12:35:11 AM: Finished saving boot dependencies
12:35:11 AM: Started saving rust rustup cache
12:35:11 AM: Finished saving rust rustup cache
12:35:11 AM: Started saving go dependencies
12:35:11 AM: Finished saving go dependencies
12:35:12 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:35:12 AM: Creating deploy upload records
12:35:12 AM: Failing build: Failed to build site
12:35:12 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)
12:35:12 AM: Finished processing build request in 1m10.163720236s

Thanks!

Thanks @juanmarkus

The issue is the build command here

There is no space between CI and =. The command should read

CI= npm run build

However, I am also curious why you are running the command yarn build in the first place when it it calling CI= npm run build? yarn build is the equivalent of npm run build. Instead of using yarn build, you should likely simply use CI= npm run build.

Thanks for replying. I am using yarn for the commands during the development, I guess it just automatically calls our yarn?
I tried fixing the build command, but now it seems to be returning a glitch with the log like this:

11:57:24 AM: > CI= npm run build
11:57:25 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
11:57:25 AM: npm WARN config location in the cache, and they are managed by
11:57:25 AM: npm WARN config cacache.
11:57:25 AM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
11:57:25 AM: npm WARN config location in the cache, and they are managed by
11:57:25 AM: npm WARN config cacache.

Thanks!

Can you share the repository you are deploying from?

Yes, it is from a private repository in github. Here is the link: https://github.com/rubinetwork/rubilink

Thanks!

If it’s private, I can’t see it. If I can’t see it I can’t tell you what is (possibly) wrong and stopping you from deploying.

I just made it public, so I think you can see it now.

First issue I see is the build script in the package.json calls itself

"build": "CI= npm run build",

So when you run yarn build or CI= npm run build, that runs the build script from the package.json. That is then going to run the same command.

The correct build command is

"build": "react-scripts build"

You need to then set the build command in the Netlify UI to npm run build (or CI= npm run build if you want CI to equal false.)

You’ll find more information about building and deploying React on

Hi, I just tried everything and it didn’t work. It worked perfectly until a few days ago, and suddenly it occurred.

As you’ve made the repository private again, there’s little more I can offer in the way of assistance.

Sorry for the trouble. I just made it public again. Thanks!

You haven’t changed the build script. It is still CI= npm run build so when you run CI= npm run build it calls itself.

@juanmarkus

I have cloned and successfully deployed your project.

The first issue is a conflict with dependencies. In order to overcome these, you need to add the environment variable NPM_FLAGS with the value --force.

Second issue is Netlify recognises the project you are trying to deploy as a Next.js site because you have next as a dependency even though you are not using it. So what happens is Netlify automatically set the publish directory to .next. The issue is, the site is built using React, not Next.js, so the publish directory is build, not .next

It also automatically runs the Next Runtime plugin, which fails because it is not a Next.js site. In order to skip this plugin (without removing the next dependency) you need to add the environment variable NETLIFY_NEXT_PLUGIN_SKIP with the value true. (However, if you aren’t using this dependency, you might just as easily remove it.)

Another thing to note is that generally (even on a private repository) you wouldn’t commit a .env file contain private/secret information.

1 Like

Thank you very much! That’s weird considering I have pushed the latest edit earlier today.
Thanks for the support!!

Hello, I tried to follow your instructions and tried to deploy the updated website again today, but still it didn’t work. Not sure again where the problem is, but I have set the environment variable and everything accordingly.

As you have not provided the deploy log, I have no idea what the error was. Can you share it? And can you make the repository public again?