React Scripts Syntax Error on Build

Having an issue doing a deploy to prod.

*netlify site name: naughty-ritchie-3030d6.netlify.app

This is a Create React App that is failing on build to production. Also just changed build image from Ubuntu Xenial to the default Ubuntu Focal 20.04

Here is the logs. If I build this locally I am not coming across this issue.

5:57:46 PM: Build ready to start
5:58:08 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
5:58:08 PM: build-image tag: v4.10.1
5:58:08 PM: buildbot version: 37262c48b1f3cfa88c6caed707d29b19aef6a5a7
5:58:08 PM: Fetching cached dependencies
5:58:08 PM: Failed to fetch cache, continuing with build
5:58:08 PM: Starting to prepare the repo for build
5:58:08 PM: No cached dependencies found. Cloning fresh repo
5:58:08 PM: git clone https://github.com/tairemad/tai
5:58:09 PM: Preparing Git Reference refs/heads/main
5:58:09 PM: Parsing package.json dependencies
5:58:10 PM: Starting build script
5:58:10 PM: Installing dependencies
5:58:10 PM: Python version set to 2.7
5:58:11 PM: Downloading and installing node v10.24.1...
5:58:11 PM: Downloading https://nodejs.org/dist/v10.24.1/node-v10.24.1-linux-x64.tar.xz...
5:58:11 PM: Computing checksum with sha256sum
5:58:11 PM: Checksums matched!
5:58:12 PM: Now using node v10.24.1 (npm v6.14.12)
5:58:12 PM: Started restoring cached build plugins
5:58:12 PM: Finished restoring cached build plugins
5:58:12 PM: Attempting ruby version 2.6.2, read from environment
5:58:13 PM: Required ruby-2.6.2 is not installed - installing.
5:58:13 PM: Searching for binary rubies, this might take some time.
5:58:13 PM: Found remote file https://rvm_io.global.ssl.fastly.net/binaries/ubuntu/20.04/x86_64/ruby-2.6.2.tar.bz2
5:58:13 PM: Checking requirements for ubuntu.
5:58:13 PM: Requirements installation successful.
5:58:13 PM: ruby-2.6.2 - #configure
5:58:13 PM: ruby-2.6.2 - #download
5:58:14 PM: ruby-2.6.2 - #validate archive
5:58:17 PM: ruby-2.6.2 - #extract
5:58:19 PM: ruby-2.6.2 - #validate binary
5:58:19 PM: ruby-2.6.2 - #setup
5:58:19 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2@global
5:58:19 PM: ruby-2.6.2 - #importing gemset /opt/buildhome/.rvm/gemsets/global.gems........................................
5:58:20 PM: ruby-2.6.2 - #generating global wrappers........
5:58:20 PM: ruby-2.6.2 - #gemset created /opt/buildhome/.rvm/gems/ruby-2.6.2
5:58:20 PM: ruby-2.6.2 - #importing gemsetfile /opt/buildhome/.rvm/gemsets/default.gems evaluated to empty gem list
5:58:20 PM: ruby-2.6.2 - #generating default wrappers........
5:58:20 PM: Using /opt/buildhome/.rvm/gems/ruby-2.6.2
5:58:21 PM: Using ruby version 2.6.2
5:58:21 PM: Using PHP version 8.0
5:58:21 PM: No npm workspaces detected
5:58:21 PM: Started restoring cached node modules
5:58:21 PM: Finished restoring cached node modules
5:58:21 PM: Installing NPM modules using NPM version 6.14.12
5:58:38 PM: npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
5:58:38 PM: > @fortawesome/fontawesome-common-types@6.2.0 postinstall /opt/build/repo/node_modules/@fortawesome/fontawesome-common-types
5:58:38 PM: > node attribution.js
5:58:38 PM: Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
5:58:38 PM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
5:58:38 PM: Copyright 2022 Fonticons, Inc.
5:58:38 PM: > core-js@3.25.0 postinstall /opt/build/repo/node_modules/core-js
5:58:38 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:58:38 PM: > core-js-pure@3.25.0 postinstall /opt/build/repo/node_modules/core-js-pure
5:58:38 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:58:38 PM: > @fortawesome/fontawesome-svg-core@6.2.0 postinstall /opt/build/repo/node_modules/@fortawesome/fontawesome-svg-core
5:58:38 PM: > node attribution.js
5:58:38 PM: Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
5:58:38 PM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
5:58:38 PM: Copyright 2022 Fonticons, Inc.
5:58:38 PM: > @fortawesome/free-brands-svg-icons@6.2.0 postinstall /opt/build/repo/node_modules/@fortawesome/free-brands-svg-icons
5:58:38 PM: > node attribution.js
5:58:38 PM: Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
5:58:38 PM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
5:58:38 PM: Copyright 2022 Fonticons, Inc.
5:58:38 PM: > @fortawesome/free-regular-svg-icons@6.2.0 postinstall /opt/build/repo/node_modules/@fortawesome/free-regular-svg-icons
5:58:38 PM: > node attribution.js
5:58:38 PM: Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
5:58:38 PM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
5:58:38 PM: Copyright 2022 Fonticons, Inc.
5:58:38 PM: > @fortawesome/free-solid-svg-icons@6.2.0 postinstall /opt/build/repo/node_modules/@fortawesome/free-solid-svg-icons
5:58:38 PM: > node attribution.js
5:58:38 PM: Font Awesome Free 6.2.0 by @fontawesome - https://fontawesome.com
5:58:38 PM: License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
5:58:38 PM: Copyright 2022 Fonticons, Inc.
5:58:39 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents):
5:58:39 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:58:39 PM: added 1454 packages from 700 contributors and audited 1455 packages in 17.119s
5:58:39 PM: 209 packages are looking for funding
5:58:39 PM:   run `npm fund` for details
5:58:39 PM: found 1 high severity vulnerability
5:58:39 PM:   run `npm audit fix` to fix them, or `npm audit` for details
5:58:39 PM: NPM modules installed
5:58:40 PM: Started restoring cached go cache
5:58:40 PM: Finished restoring cached go cache
5:58:40 PM: Installing Go version 1.12 (requested 1.12)
5:58:44 PM: unset GOOS;
5:58:44 PM: unset GOARCH;
5:58:44 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
5:58:44 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
5:58:44 PM: go version >&2;
5:58:44 PM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.12.linux.amd64.env"
5:58:44 PM: go version go1.12 linux/amd64
5:58:44 PM: Installing missing commands
5:58:44 PM: Verify run directory
5:58:45 PM: ​
5:58:45 PM: ────────────────────────────────────────────────────────────────
5:58:45 PM:   Netlify Build                                                 
5:58:45 PM: ────────────────────────────────────────────────────────────────
5:58:45 PM: ​
5:58:45 PM: ❯ Version
5:58:45 PM:   @netlify/build 27.17.1
5:58:45 PM: ​
5:58:45 PM: ❯ Flags
5:58:45 PM:   baseRelDir: true
5:58:45 PM:   buildId: 631913da262eba0069087c90
5:58:45 PM:   deployId: 631913da262eba0069087c92
5:58:45 PM: ​
5:58:45 PM: ❯ Current directory
5:58:45 PM:   /opt/build/repo
5:58:45 PM: ​
5:58:45 PM: ❯ Config file
5:58:45 PM:   No config file was defined: using default values.
5:58:45 PM: ​
5:58:45 PM: ❯ Context
5:58:45 PM:   production
5:58:45 PM: ​
5:58:45 PM: ────────────────────────────────────────────────────────────────
5:58:45 PM:   1. Build command from Netlify app                             
5:58:45 PM: ────────────────────────────────────────────────────────────────
5:58:45 PM: ​
5:58:45 PM: $ npm run build
5:58:45 PM: > tai@0.1.0 build /opt/build/repo
5:58:45 PM: > react-scripts build
5:58:46 PM: /opt/build/repo/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
5:58:46 PM:   _ending;
5:58:46 PM:          ^
5:58:46 PM: SyntaxError: Unexpected token ;
5:58:46 PM:     at Module._compile (internal/modules/cjs/loader.js:723:23)
5:58:46 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
5:58:46 PM:     at Module.load (internal/modules/cjs/loader.js:653:32)
5:58:46 PM:     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
5:58:46 PM:     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
5:58:46 PM:     at Module.require (internal/modules/cjs/loader.js:692:17)
5:58:46 PM:     at require (internal/modules/cjs/helpers.js:25:18)
5:58:46 PM:     at Object.<anonymous> (/opt/build/repo/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
5:58:46 PM:     at Module._compile (internal/modules/cjs/loader.js:778:30)
5:58:46 PM:     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
5:58:46 PM: npm ERR! code ELIFECYCLE
5:58:46 PM: npm ERR! errno 1
5:58:46 PM: npm ERR! tai@0.1.0 build: `react-scripts build`
5:58:46 PM: npm ERR! Exit status 1
5:58:46 PM: npm ERR!
5:58:46 PM: npm ERR! Failed at the tai@0.1.0 build script.
5:58:46 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:58:46 PM: npm ERR! A complete log of this run can be found in:
5:58:46 PM: npm ERR!     /opt/buildhome/.npm/_logs/2022-09-07T21_58_46_337Z-debug.log
5:58:46 PM: ​
5:58:46 PM: ────────────────────────────────────────────────────────────────
5:58:46 PM:   "build.command" failed                                        
5:58:46 PM: ────────────────────────────────────────────────────────────────
5:58:46 PM: ​
5:58:46 PM:   Error message
5:58:46 PM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
5:58:46 PM: ​
5:58:46 PM:   Error location
5:58:46 PM:   In Build command from Netlify app:
5:58:46 PM:   npm run build
5:58:46 PM: ​
5:58:46 PM:   Resolved config
5:58:46 PM:   build:
5:58:46 PM:     command: npm run build
5:58:46 PM:     commandOrigin: ui
5:58:46 PM:     publish: /opt/build/repo/public
5:58:46 PM:     publishOrigin: ui
5:58:46 PM: Caching artifacts
5:58:46 PM: Started saving node modules
5:58:46 PM: Finished saving node modules
5:58:46 PM: Started saving build plugins
5:58:46 PM: Finished saving build plugins
5:58:46 PM: Started saving pip cache
5:58:46 PM: Finished saving pip cache
5:58:46 PM: Started saving emacs cask dependencies
5:58:46 PM: Finished saving emacs cask dependencies
5:58:46 PM: Started saving maven dependencies
5:58:46 PM: Finished saving maven dependencies
5:58:46 PM: Started saving boot dependencies
5:58:46 PM: Finished saving boot dependencies
5:58:46 PM: Started saving rust rustup cache
5:58:46 PM: Finished saving rust rustup cache
5:58:46 PM: Started saving go dependencies
5:58:46 PM: Finished saving go dependencies
5:58:48 PM: Cached ruby version 2.6.2
5:58:48 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
5:58:48 PM: Creating deploy upload records
5:58:48 PM: Failing build: Failed to build site
5:58:48 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
5:58:49 PM: Finished processing build request in 40.973345021s

Hey @tairemad,

This appears to be some issue with Jest: https://github.com/facebook/jest/issues/6933. It looks like from time to time, it randomly reports some weird syntax errors.

I did have a test error that I fixed but the logs are still showing the same error on build…create react app hides all the babel and config files. I wonder if I expose them and try to update a config will this really solve the issue?

Can’t say. That’s a possibility you’d have to explore. Take a backup of your project and feel free to continue the investigation.

I ended up fixing the test and updating node and npm version on my site and this no longer the issue I am having…now its a new timeout issue