4

I can't figure out why I can deploy perfectly locally but not working when I manually dropped the build folder online or add my repo with Github method. I got the error like below:

10:21:21 PM: Build ready to start 10:21:22 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68 10:21:22 PM: build-image tag: v3.6.1 10:21:22 PM: buildbot version: 44655717ddf0e7bd7f856f5b1154254de54b1d80 10:21:23 PM: Building without cache 10:21:23 PM: Starting to prepare the repo for build 10:21:23 PM: No cached dependencies found. Cloning fresh repo 10:21:23 PM: git clone https://github.com/celinevalentine/Games 10:21:24 PM: Preparing Git Reference refs/heads/celinev 10:21:26 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI 10:21:26 PM: Starting build script 10:21:26 PM: Installing dependencies 10:21:26 PM: Python version set to 2.7 10:21:27 PM: v12.18.0 is already installed. 10:21:28 PM: Now using node v12.18.0 (npm v6.14.4) 10:21:28 PM: Started restoring cached build plugins 10:21:28 PM: Finished restoring cached build plugins 10:21:28 PM: Attempting ruby version 2.7.1, read from environment 10:21:29 PM: Using ruby version 2.7.1 10:21:29 PM: Using PHP version 5.6 10:21:29 PM: Started restoring cached go cache 10:21:29 PM: Finished restoring cached go cache 10:21:29 PM: go version go1.14.4 linux/amd64 10:21:29 PM: go version go1.14.4 linux/amd64 10:21:29 PM: Installing missing commands 10:21:29 PM: Verify run directory 10:21:31 PM: ​ 10:21:31 PM: ──────────────────────────────────────────────────────────────── 10:21:31 PM: Netlify Build
10:21:31 PM: ──────────────────────────────────────────────────────────────── 10:21:31 PM: ​ 10:21:31 PM: ❯ Version 10:21:31 PM: @netlify/build 8.3.0 10:21:31 PM: ​ 10:21:31 PM: ❯ Flags 10:21:31 PM: deployId: 6014fae1970bcf9dcb4a28eb 10:21:31 PM: mode: buildbot 10:21:31 PM: ​ 10:21:31 PM: ❯ Current directory 10:21:31 PM: /opt/build/repo 10:21:31 PM: ​ 10:21:31 PM: ❯ Config file 10:21:31 PM: No config file was defined: using default values. 10:21:31 PM: ​ 10:21:31 PM: ❯ Context 10:21:31 PM: production 10:21:31 PM: ​ 10:21:31 PM: ──────────────────────────────────────────────────────────────── 10:21:31 PM: 1. Build command from Netlify app
10:21:31 PM: ──────────────────────────────────────────────────────────────── 10:21:31 PM: ​ 10:21:31 PM: $ npm run build 10:21:31 PM: npm ERR! code ENOENT 10:21:31 PM: npm ERR! syscall open 10:21:31 PM: npm ERR! path /opt/build/repo/package.json 10:21:31 PM: npm ERR! errno -2 10:21:31 PM: npm ERR! enoent ENOENT: no such file or directory, open '/opt/build/repo/package.json' 10:21:31 PM: npm ERR! enoent This is related to npm not being able to find a file. 10:21:31 PM: npm ERR! enoent 10:21:31 PM: npm ERR! A complete log of this run can be found in: 10:21:31 PM: npm ERR!
/opt/buildhome/.npm/_logs/2021-01-30T06_21_31_988Z-debug.log 10:21:32 PM: ​ 10:21:32 PM: ──────────────────────────────────────────────────────────────── 10:21:32 PM: "build.command" failed
10:21:32 PM: ──────────────────────────────────────────────────────────────── 10:21:32 PM: ​ 10:21:32 PM: Error message 10:21:32 PM: Command failed with exit code 254: npm run build 10:21:32 PM: ​ 10:21:32 PM:
Error location 10:21:32 PM: In Build command from Netlify app: 10:21:32 PM: npm run build 10:21:32 PM: ​ 10:21:32 PM: Resolved config 10:21:32 PM: build: 10:21:32 PM: command: npm run build 10:21:32 PM: commandOrigin: ui 10:21:32 PM: publish: /opt/build/repo/build 10:21:32 PM: Caching artifacts 10:21:32 PM: Started saving build plugins 10:21:32 PM: Finished saving build plugins 10:21:32 PM: Started saving pip cache 10:21:32 PM: Finished saving pip cache 10:21:32 PM: Started saving emacs cask dependencies 10:21:32 PM: Finished saving emacs cask dependencies 10:21:32 PM: Started saving maven dependencies 10:21:32 PM: Finished saving maven dependencies 10:21:32 PM: Started saving boot dependencies 10:21:32 PM: Finished saving boot dependencies 10:21:32 PM: Started saving rust rustup cache 10:21:32 PM: Finished saving rust rustup cache 10:21:32 PM: Started saving go dependencies 10:21:32 PM: Finished saving go dependencies 10:21:35 PM: Build failed due to a user error: Build script returned non-zero exit code: 2 10:21:35 PM: Failing build: Failed to build site 10:21:35 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 10:21:35 PM: Finished processing build request in 12.138963808s

1
  • did you find any solution?? Commented Apr 24, 2022 at 15:28

2 Answers 2

7

Please try

CI= npm run build

instead of the -> npm run build

Sign up to request clarification or add additional context in comments.

Comments

1

To fix this issue go to you're site dashborad on netify. Then site setting and open Build & deploy tab from general. click on edit settings in Build setting area. and change build command to CI= npm run build

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.