Home
Support Forums

Failed Deployment from CRA Project

Hi, I’m new to Netlify and was trying to launch my first website built with Create React App.

Please help me understand this error. I ran the npm run build command and linked the project to the github repo. But when I try to build and deploy on Netlify, it fails and I get this error.


10:51:57 AM: Build ready to start
10:51:59 AM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
10:51:59 AM: build-image tag: v3.8.0
10:51:59 AM: buildbot version: 50f65aefac6a0b0332883c4b4311845d6395ce2b
10:51:59 AM: Fetching cached dependencies
10:51:59 AM: Failed to fetch cache, continuing with build
10:51:59 AM: Starting to prepare the repo for build
10:52:00 AM: No cached dependencies found. Cloning fresh repo
10:52:00 AM: git clone https://github.com/dan-ville/personal-website
10:52:01 AM: Preparing Git Reference refs/heads/main
10:52:02 AM: Parsing package.json dependencies
10:52:03 AM: Starting build script
10:52:03 AM: Installing dependencies
10:52:03 AM: Python version set to 2.7
10:52:04 AM: v12.18.0 is already installed.
10:52:05 AM: Now using node v12.18.0 (npm v6.14.4)
10:52:05 AM: Started restoring cached build plugins
10:52:05 AM: Finished restoring cached build plugins
10:52:05 AM: Attempting ruby version 2.7.2, read from environment
10:52:07 AM: Using ruby version 2.7.2
10:52:07 AM: Using PHP version 5.6
10:52:07 AM: Started restoring cached yarn cache
10:52:07 AM: Finished restoring cached yarn cache
10:52:07 AM: Installing yarn at version 1.22.10
10:52:07 AM: Installing Yarn!
10:52:07 AM: > Downloading tarball...
10:52:07 AM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz --> /tmp/yarn.tar.gz.zFa8ifOyP9
10:52:07 AM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
10:52:07 AM:                                  Dload  Upload   Total   Spent    Left  Speed
10:52:08 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
10:52:08 AM: 100    81  100    81    0     0    318      0 --:--:-- --:--:-- --:--:--   318
10:52:08 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
10:52:08 AM: 100    95  100    95    0     0    148      0 --:--:-- --:--:-- --:--:--   293
10:52:08 AM: 100   626  100   626    0     0    680      0 --:--:-- --:--:-- --:--:--   680
10:52:09 AM: 100 1215k  100 1215k    0     0   953k      0  0:00:01  0:00:01 --:--:--  953k
10:52:09 AM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc --> /tmp/yarn.tar.gz.zFa8ifOyP9.asc
10:52:09 AM: 100    85  100    85    0     0   1588      0 --:--:-- --:--:-- --:--:--  1588
10:52:09 AM: 100    85  100    85    0     0   1540      0 --:--:-- --:--:-- --:--:--     0
10:52:09 AM: 100    99  100    99    0     0   1142      0 --:--:-- --:--:-- --:--:--  1142
10:52:09 AM: 100   630  100   630    0     0   5556      0 --:--:-- --:--:-- --:--:--  5556
10:52:09 AM: 100   832  100   832    0     0   5898      0 --:--:-- --:--:-- --:--:--  5898
10:52:09 AM: > Verifying integrity...
10:52:09 AM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC using RSA key ID 69475BAA
10:52:09 AM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
10:52:09 AM: gpg: WARNING: This key is not certified with a trusted signature!
10:52:09 AM: gpg:          There is no indication that the signature belongs to the owner.
10:52:09 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
10:52:09 AM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
10:52:09 AM: > GPG signature looks good
10:52:09 AM: > Extracting to ~/.yarn...
10:52:09 AM: > Adding to $PATH...
10:52:09 AM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
10:52:10 AM: No yarn workspaces detected
10:52:10 AM: Started restoring cached node modules
10:52:10 AM: Finished restoring cached node modules
10:52:10 AM: Installing NPM modules using Yarn version 1.22.10
10:52:11 AM: yarn install v1.22.10
10:52:11 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
10:52:11 AM: [1/4] Resolving packages...
10:52:12 AM: warning react-scripts > webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
10:52:13 AM: [2/4] Fetching packages...
10:52:36 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
10:52:36 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
10:52:36 AM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
10:52:36 AM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
10:52:36 AM: [3/4] Linking dependencies...
10:52:36 AM: warning " > @testing-library/user-event@12.8.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
10:52:36 AM: warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.20.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
10:52:50 AM: [4/4] Building fresh packages...
10:52:51 AM: success Saved lockfile.
10:52:51 AM: Done in 40.50s.
10:52:51 AM: NPM modules installed using Yarn
10:52:52 AM: Started restoring cached go cache
10:52:52 AM: Finished restoring cached go cache
10:52:52 AM: go version go1.14.4 linux/amd64
10:52:52 AM: go version go1.14.4 linux/amd64
10:52:52 AM: Installing missing commands
10:52:52 AM: Verify run directory
10:52:52 AM: ​
10:52:52 AM: ────────────────────────────────────────────────────────────────
10:52:52 AM:   Netlify Build                                                 
10:52:52 AM: ────────────────────────────────────────────────────────────────
10:52:52 AM: ​
10:52:52 AM: ❯ Version
10:52:52 AM:   @netlify/build 12.4.0
10:52:52 AM: ​
10:52:52 AM: ❯ Flags
10:52:52 AM:   deployId: 60ccb30dcd12ea10f53f73e0
10:52:52 AM: ​
10:52:52 AM: ❯ Current directory
10:52:52 AM:   /opt/build/repo
10:52:52 AM: ​
10:52:52 AM: ❯ Config file
10:52:52 AM:   No config file was defined: using default values.
10:52:52 AM: ​
10:52:52 AM: ❯ Context
10:52:52 AM:   production
10:52:52 AM: ​
10:52:52 AM: ────────────────────────────────────────────────────────────────
10:52:52 AM:   1. Build command from Netlify app                             
10:52:52 AM: ────────────────────────────────────────────────────────────────
10:52:52 AM: ​
10:52:52 AM: $ npm run build
10:52:53 AM: > personal-website@0.1.0 build /opt/build/repo
10:52:53 AM: > react-scripts build
10:52:55 AM: Creating an optimized production build...
10:53:08 AM: 
10:53:08 AM: Treating warnings as errors because process.env.CI = true.
10:53:08 AM: Most CI servers set it automatically.
10:53:08 AM: 
10:53:08 AM: Failed to compile.
10:53:08 AM: 
10:53:08 AM: src/App.js
10:53:08 AM:   Line 3:50:  'Link' is defined but never used  no-unused-vars
10:53:08 AM: src/components/SocialsBar.js
10:53:08 AM:   Line 8:11:  'SocialLink' is assigned a value but never used  no-unused-vars
10:53:08 AM: src/routes/Home.js
10:53:08 AM:   Line 2:10:  'Chevron' is defined but never used  no-unused-vars
10:53:08 AM: npm ERR! code ELIFECYCLE
10:53:08 AM: npm ERR! errno 1
10:53:08 AM: npm ERR! personal-website@0.1.0 build: `react-scripts build`
10:53:08 AM: npm ERR! Exit status 1
10:53:08 AM: npm ERR!
10:53:08 AM: npm ERR! Failed at the personal-website@0.1.0 build script.
10:53:08 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:53:08 AM: npm ERR! A complete log of this run can be found in:
10:53:08 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-06-18T14_53_08_499Z-debug.log
10:53:08 AM: ​
10:53:08 AM: ────────────────────────────────────────────────────────────────
10:53:08 AM:   "build.command" failed                                        
10:53:08 AM: ────────────────────────────────────────────────────────────────
10:53:08 AM: ​
10:53:08 AM:   Error message
10:53:08 AM:   Command failed with exit code 1: npm run build
10:53:08 AM: ​
10:53:08 AM:   Error location
10:53:08 AM:   In Build command from Netlify app:
10:53:08 AM:   npm run build
10:53:08 AM: ​
10:53:08 AM:   Resolved config
10:53:08 AM:   build:
10:53:08 AM:     command: npm run build
10:53:08 AM:     commandOrigin: ui
10:53:08 AM:     publish: /opt/build/repo/build
10:53:08 AM:   functions:
10:53:08 AM:     '*': {}
10:53:08 AM: Caching artifacts
10:53:08 AM: Started saving node modules
10:53:08 AM: Finished saving node modules
10:53:08 AM: Started saving build plugins
10:53:08 AM: Finished saving build plugins
10:53:08 AM: Started saving yarn cache
10:53:08 AM: Finished saving yarn cache
10:53:08 AM: Started saving pip cache
10:53:09 AM: Finished saving pip cache
10:53:09 AM: Started saving emacs cask dependencies
10:53:09 AM: Finished saving emacs cask dependencies
10:53:09 AM: Started saving maven dependencies
10:53:09 AM: Finished saving maven dependencies
10:53:09 AM: Started saving boot dependencies
10:53:09 AM: Finished saving boot dependencies
10:53:09 AM: Started saving rust rustup cache
10:53:09 AM: Finished saving rust rustup cache
10:53:09 AM: Started saving go dependencies
10:53:09 AM: Finished saving go dependencies
10:53:12 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:53:12 AM: Creating deploy upload records
10:53:12 AM: Failing build: Failed to build site
10:53:12 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:53:12 AM: Finished processing build request in 1m12.753224759s

Change your build command to CI= npm run build.

Hello, I tried that as well but I got a similar error.

10:55:49 AM: Build ready to start
10:55:51 AM: build-image version: 2cee85eb7f808bf3b6e87378c5307f9411f0a332
10:55:51 AM: build-image tag: v3.8.0
10:55:51 AM: buildbot version: 50f65aefac6a0b0332883c4b4311845d6395ce2b
10:55:51 AM: Fetching cached dependencies
10:55:51 AM: Failed to fetch cache, continuing with build
10:55:51 AM: Starting to prepare the repo for build
10:55:51 AM: No cached dependencies found. Cloning fresh repo
10:55:51 AM: git clone https://github.com/dan-ville/personal-website
10:55:53 AM: Preparing Git Reference refs/heads/main
10:55:53 AM: Parsing package.json dependencies
10:55:54 AM: Starting build script
10:55:54 AM: Installing dependencies
10:55:54 AM: Python version set to 2.7
10:55:55 AM: v12.18.0 is already installed.
10:55:55 AM: Now using node v12.18.0 (npm v6.14.4)
10:55:55 AM: Started restoring cached build plugins
10:55:55 AM: Finished restoring cached build plugins
10:55:56 AM: Attempting ruby version 2.7.2, read from environment
10:55:57 AM: Using ruby version 2.7.2
10:55:57 AM: Using PHP version 5.6
10:55:57 AM: Started restoring cached yarn cache
10:55:57 AM: Finished restoring cached yarn cache
10:55:57 AM: Installing yarn at version 1.22.10
10:55:57 AM: Installing Yarn!
10:55:57 AM: > Downloading tarball...
10:55:57 AM: [1/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz --> /tmp/yarn.tar.gz.gfUaPyVyph
10:55:57 AM:   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
10:55:57 AM:                                  Dload  Upload   Total   Spent    Left  Speed
10:55:57 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
10:55:57 AM: 100    81  100    81    0     0    441      0 --:--:-- --:--:-- --:--:--   442
10:55:58 AM:   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
10:55:58 AM: 100    95  100    95    0     0    179      0 --:--:-- --:--:-- --:--:--   301
10:55:58 AM: 100   626  100   626    0     0    785      0 --:--:-- --:--:-- --:--:--   785
10:55:58 AM: 100 1215k  100 1215k    0     0  1087k      0  0:00:01  0:00:01 --:--:-- 1087k
10:55:58 AM: [2/2]: https://yarnpkg.com/downloads/1.22.10/yarn-v1.22.10.tar.gz.asc --> /tmp/yarn.tar.gz.gfUaPyVyph.asc
10:55:58 AM: 100    85  100    85    0     0   1599      0 --:--:-- --:--:-- --:--:--  1599
10:55:58 AM: 100    99  100    99    0     0   1179      0 --:--:-- --:--:-- --:--:--  1179
10:55:58 AM: 100    99  100    99    0     0   1178      0 --:--:-- --:--:-- --:--:--     0
10:55:58 AM: 100   630  100   630    0     0   5675      0 --:--:-- --:--:-- --:--:--  5675
10:55:58 AM: 100   832  100   832    0     0   6802      0 --:--:-- --:--:-- --:--:--  6802
10:55:58 AM: > Verifying integrity...
10:55:58 AM: gpg: Signature made Fri 02 Oct 2020 11:17:27 AM UTC using RSA key ID 69475BAA
10:55:58 AM: gpg: Good signature from "Yarn Packaging <yarn@dan.cx>"
10:55:58 AM: gpg: WARNING: This key is not certified with a trusted signature!
10:55:58 AM: gpg:          There is no indication that the signature belongs to the owner.
10:55:58 AM: Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
10:55:58 AM:      Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
10:55:58 AM: > GPG signature looks good
10:55:58 AM: > Extracting to ~/.yarn...
10:55:59 AM: > Adding to $PATH...
10:55:59 AM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
10:55:59 AM: No yarn workspaces detected
10:55:59 AM: Started restoring cached node modules
10:55:59 AM: Finished restoring cached node modules
10:55:59 AM: Installing NPM modules using Yarn version 1.22.10
10:56:00 AM: yarn install v1.22.10
10:56:00 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
10:56:00 AM: [1/4] Resolving packages...
10:56:01 AM: warning react-scripts > webpack-dev-server > chokidar > fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
10:56:01 AM: [2/4] Fetching packages...
10:56:22 AM: info fsevents@2.3.2: The platform "linux" is incompatible with this module.
10:56:22 AM: info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
10:56:22 AM: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
10:56:22 AM: info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
10:56:22 AM: [3/4] Linking dependencies...
10:56:22 AM: warning " > @testing-library/user-event@12.8.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
10:56:22 AM: warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.20.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
10:56:34 AM: [4/4] Building fresh packages...
10:56:35 AM: success Saved lockfile.
10:56:35 AM: Done in 35.36s.
10:56:35 AM: NPM modules installed using Yarn
10:56:36 AM: Started restoring cached go cache
10:56:36 AM: Finished restoring cached go cache
10:56:36 AM: go version go1.14.4 linux/amd64
10:56:36 AM: go version go1.14.4 linux/amd64
10:56:36 AM: Installing missing commands
10:56:36 AM: Verify run directory
10:56:36 AM: ​
10:56:36 AM: ────────────────────────────────────────────────────────────────
10:56:36 AM:   Netlify Build                                                 
10:56:36 AM: ────────────────────────────────────────────────────────────────
10:56:36 AM: ​
10:56:36 AM: ❯ Version
10:56:36 AM:   @netlify/build 12.4.0
10:56:36 AM: ​
10:56:36 AM: ❯ Flags
10:56:36 AM:   deployId: 60ccb3f51461d1083f93833c
10:56:36 AM: ​
10:56:36 AM: ❯ Current directory
10:56:36 AM:   /opt/build/repo
10:56:36 AM: ​
10:56:36 AM: ❯ Config file
10:56:36 AM:   No config file was defined: using default values.
10:56:36 AM: ​
10:56:36 AM: ❯ Context
10:56:36 AM:   production
10:56:36 AM: ​
10:56:36 AM: ────────────────────────────────────────────────────────────────
10:56:36 AM:   1. Build command from Netlify app                             
10:56:36 AM: ────────────────────────────────────────────────────────────────
10:56:36 AM: ​
10:56:36 AM: $ CI=true npm run build
10:56:36 AM: > personal-website@0.1.0 build /opt/build/repo
10:56:36 AM: > react-scripts build
10:56:38 AM: Creating an optimized production build...
10:56:50 AM: 
10:56:50 AM: Treating warnings as errors because process.env.CI = true.
10:56:50 AM: Most CI servers set it automatically.
10:56:50 AM: 
10:56:50 AM: Failed to compile.
10:56:50 AM: 
10:56:50 AM: src/App.js
10:56:50 AM:   Line 3:50:  'Link' is defined but never used  no-unused-vars
10:56:50 AM: src/components/SocialsBar.js
10:56:50 AM:   Line 8:11:  'SocialLink' is assigned a value but never used  no-unused-vars
10:56:50 AM: src/routes/Home.js
10:56:50 AM:   Line 2:10:  'Chevron' is defined but never used  no-unused-vars
10:56:50 AM: npm ERR! code ELIFECYCLE
10:56:50 AM: npm ERR! errno 1
10:56:50 AM: npm ERR! personal-website@0.1.0 build: `react-scripts build`
10:56:50 AM: npm ERR! Exit status 1
10:56:50 AM: npm ERR!
10:56:50 AM: npm ERR! Failed at the personal-website@0.1.0 build script.
10:56:50 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:56:50 AM: npm ERR! A complete log of this run can be found in:
10:56:50 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-06-18T14_56_50_248Z-debug.log
10:56:50 AM: ​
10:56:50 AM: ────────────────────────────────────────────────────────────────
10:56:50 AM:   "build.command" failed                                        
10:56:50 AM: ────────────────────────────────────────────────────────────────
10:56:50 AM: ​
10:56:50 AM:   Error message
10:56:50 AM:   Command failed with exit code 1: CI=true npm run build
10:56:50 AM: ​
10:56:50 AM:   Error location
10:56:50 AM:   In Build command from Netlify app:
10:56:50 AM:   CI=true npm run build
10:56:50 AM: ​
10:56:50 AM:   Resolved config
10:56:50 AM:   build:
10:56:50 AM:     command: CI=true npm run build
10:56:50 AM:     commandOrigin: ui
10:56:50 AM:     publish: /opt/build/repo/build
10:56:50 AM:   functions:
10:56:50 AM:     '*': {}
10:56:50 AM: Caching artifacts
10:56:50 AM: Started saving node modules
10:56:50 AM: Finished saving node modules
10:56:50 AM: Started saving build plugins
10:56:50 AM: Finished saving build plugins
10:56:50 AM: Started saving yarn cache
10:56:50 AM: Finished saving yarn cache
10:56:50 AM: Started saving pip cache
10:56:50 AM: Finished saving pip cache
10:56:50 AM: Started saving emacs cask dependencies
10:56:50 AM: Finished saving emacs cask dependencies
10:56:50 AM: Started saving maven dependencies
10:56:50 AM: Finished saving maven dependencies
10:56:50 AM: Started saving boot dependencies
10:56:50 AM: Finished saving boot dependencies
10:56:50 AM: Started saving rust rustup cache
10:56:50 AM: Finished saving rust rustup cache
10:56:50 AM: Started saving go dependencies
10:56:50 AM: Finished saving go dependencies
10:56:53 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
10:56:53 AM: Creating deploy upload records
10:56:53 AM: Failing build: Failed to build site
10:56:53 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
10:56:53 AM: Finished processing build request in 1m2.134459605s

Nevermind, I just noticed your build command was different. I had tried using CI=true npm run build based on another post. Your suggestion worked! Thank you!