Home
Support Forums

Unable to deploy react site

Hi,

I have been unable to deploy my react site to netlify. I’ve looked at the support docs, and tried

  1. Changing build command to “CI = npm run build” in netlify
  2. Changing build script to “build”: “CI= react-scripts build”, in package.json
    3)setting environment variable CI = false

but my app still fails the build.

Here’s the latest deploy log:

10:22:54 PM: Build ready to start
10:22:56 PM: build-image version: 653805ca4a64301556e56dc4b321ef8fc20cbb7c
10:22:56 PM: build-image tag: v3.8.2
10:22:56 PM: buildbot version: 32c566c80353626250182ad07e5aebc8ea63cd0e
10:22:56 PM: Fetching cached dependencies
10:22:56 PM: Failed to fetch cache, continuing with build
10:22:56 PM: Starting to prepare the repo for build
10:22:56 PM: No cached dependencies found. Cloning fresh repo
10:22:56 PM: git clone https://github.com/sohaibfurqan92/react-github-finder
10:22:57 PM: Preparing Git Reference refs/heads/master
10:22:57 PM: Parsing package.json dependencies
10:22:58 PM: Starting build script
10:22:58 PM: Installing dependencies
10:22:58 PM: Python version set to 2.7
10:22:59 PM: v12.18.0 is already installed.
10:23:00 PM: Now using node v12.18.0 (npm v6.14.4)
10:23:00 PM: Started restoring cached build plugins
10:23:00 PM: Finished restoring cached build plugins
10:23:00 PM: Attempting ruby version 2.7.2, read from environment
10:23:01 PM: Using ruby version 2.7.2
10:23:02 PM: Using PHP version 5.6
10:23:02 PM: Started restoring cached node modules
10:23:02 PM: Finished restoring cached node modules
10:23:02 PM: Installing NPM modules using NPM version 6.14.4
10:24:12 PM: > core-js@2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
10:24:12 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:24:12 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:24:12 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
10:24:12 PM: > https://opencollective.com/core-js 
10:24:12 PM: > https://www.patreon.com/zloirock 
10:24:12 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:24:13 PM: > core-js@3.9.1 postinstall /opt/build/repo/node_modules/core-js
10:24:13 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:24:13 PM: > core-js-pure@3.9.1 postinstall /opt/build/repo/node_modules/core-js-pure
10:24:13 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:24:13 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
10:24:13 PM: > node ./postinstall.js
10:24:13 PM: Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
10:24:16 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
10:24:16 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:24:16 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
10:24:16 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:24:16 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
10:24:16 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:24:16 PM: added 1959 packages from 770 contributors and audited 1962 packages in 73.15s
10:24:18 PM: 133 packages are looking for funding
10:24:18 PM:   run `npm fund` for details
10:24:18 PM: found 212 vulnerabilities (211 moderate, 1 high)
10:24:18 PM:   run `npm audit fix` to fix them, or `npm audit` for details
10:24:18 PM: NPM modules installed
10:24:18 PM: Started restoring cached go cache
10:24:18 PM: Finished restoring cached go cache
10:24:18 PM: go version go1.14.4 linux/amd64
10:24:18 PM: go version go1.14.4 linux/amd64
10:24:18 PM: Installing missing commands
10:24:18 PM: Verify run directory
10:24:19 PM: ​
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM:   Netlify Build                                                 
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM: ​
10:24:19 PM: ❯ Version
10:24:19 PM:   @netlify/build 17.2.0
10:24:19 PM: ​
10:24:19 PM: ❯ Flags
10:24:19 PM:   deployId: 6101926e9ab169490749fa6e
10:24:19 PM: ​
10:24:19 PM: ❯ Current directory
10:24:19 PM:   /opt/build/repo
10:24:19 PM: ​
10:24:19 PM: ❯ Config file
10:24:19 PM:   No config file was defined: using default values.
10:24:19 PM: ​
10:24:19 PM: ❯ Context
10:24:19 PM:   production
10:24:19 PM: ​
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM:   1. Build command from Netlify app                             
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM: ​
10:24:19 PM: $ CI= npm run build
10:24:19 PM: > github-finder@0.1.0 build /opt/build/repo
10:24:19 PM: > CI=react-scripts build
10:24:19 PM: sh: 1: build: not found
10:24:19 PM: npm ERR! code ELIFECYCLE
10:24:19 PM: npm ERR! syscall spawn
10:24:19 PM: npm ERR! file sh
10:24:19 PM: npm ERR! errno ENOENT
10:24:19 PM: npm ERR! github-finder@0.1.0 build: `CI=react-scripts build`
10:24:19 PM: npm ERR! spawn ENOENT
10:24:19 PM: npm ERR!
10:24:19 PM: npm ERR! Failed at the github-finder@0.1.0 build script.
10:24:19 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:24:19 PM: npm ERR! A complete log of this run can be found in:
10:24:19 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-07-28T17_24_19_625Z-debug.log
10:24:19 PM: ​
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM:   "build.command" failed                                        
10:24:19 PM: ────────────────────────────────────────────────────────────────
10:24:19 PM: ​
10:24:19 PM:   Error message
10:24:19 PM:   Command failed with exit code 1: CI= npm run build
10:24:19 PM: ​
10:24:19 PM:   Error location
10:24:19 PM:   In Build command from Netlify app:
10:24:19 PM:   CI= npm run build
10:24:19 PM: ​
10:24:19 PM:   Resolved config
10:24:19 PM:   build:
10:24:19 PM:     command: CI= npm run build
10:24:19 PM:     commandOrigin: ui
10:24:19 PM:     environment:
10:24:19 PM:       - CI
10:24:19 PM:     publish: /opt/build/repo/build
10:24:19 PM:     publishOrigin: ui
10:24:20 PM: Caching artifacts
10:24:20 PM: Started saving node modules
10:24:20 PM: Finished saving node modules
10:24:20 PM: Started saving build plugins
10:24:20 PM: Finished saving build plugins
10:24:20 PM: Started saving pip cache
10:24:20 PM: Finished saving pip cache
10:24:20 PM: Started saving emacs cask dependencies
10:24:20 PM: Finished saving emacs cask dependencies
10:24:20 PM: Started saving maven dependencies
10:24:20 PM: Finished saving maven dependencies
10:24:20 PM: Started saving boot dependencies
10:24:20 PM: Finished saving boot dependencies
10:24:20 PM: Started saving rust rustup cache
10:24:20 PM: Finished saving rust rustup cache
10:24:20 PM: Started saving go dependencies
10:24:20 PM: Finished saving go dependencies
10:24:22 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:24:22 PM: Creating deploy upload records
10:24:22 PM: Failing build: Failed to build site
10:24:22 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:24:23 PM: Finished processing build request in 1m26.836746275s

Can someone please help me with this?

Thanks,
Sohaib

Try updating node with netlify environment variables in build settings near the bottom. When using yarn instead of npm, there was one log mentioned this as the problem. Try anything above and including node v 12

Welcome to the forums @sohaibfurqan

I was able to deploy your code successfully. In the package.json your build command read

"build": "CI=react-scripts build",

which I changed to

"build": "CI= react-scripts build",

I set the Netlify command to yarn build (if not using yarn then npm run build).

Looking at your logs it appears you are running CI= npm run build when build is CI=react-scripts build so you end up with CI twice.

2 Likes

@coelmay Thanks very much :slight_smile:
Cheers!

1 Like