简体   繁体   中英

Netlify build Error using create-react-app (CRA) website

Getting: Build script returned non-zero exit code: 1

I have deployed my react js website code through Netlify and getting a build log and error as follows:

10:37:15 AM: Build ready to start

10:37:16 AM: build-image version: 42bca793ccd33055023c56c4ca8510463a56d317

10:37:17 AM: buildbot version: 6bab8b64bbd90091082af19fedf16bf73d502e5e

10:37:17 AM: Fetching cached dependencies

10:37:17 AM: Failed to fetch cache, continuing with build

10:37:17 AM: Starting to prepare the repo for build

10:37:17 AM: No cached dependencies found. Cloning fresh repo

10:37:17 AM: git clone git@github.com:justtabhi/react-blog-exambunker

10:37:19 AM: Preparing Git Reference refs/heads/master

10:37:20 AM: Starting build script

10:37:20 AM: Installing dependencies

10:37:21 AM: Downloading and installing node v8.12.0...

10:37:21 AM: Downloading https://nodejs.org/dist/v8.12.0/node-v8.12.0-linux-x64.tar.xz...

10:37:21 AM: 
#

10:37:21 AM:                                        1.6%

10:37:22 AM: 
#############################

10:37:22 AM:                                             40.8%

10:37:22 AM: 
#####################################

10:37:22 AM: ################################### 100.0%

10:37:22 AM: Computing checksum with sha256sum

10:37:22 AM: Checksums matched!

10:37:24 AM: Now using node v8.12.0 (npm v6.4.1)

10:37:24 AM: Attempting ruby version 2.3.6, read from environment

10:37:25 AM: Using ruby version 2.3.6

10:37:26 AM: Using PHP version 5.6

10:37:26 AM: Started restoring cached node modules

10:37:26 AM: Finished restoring cached node modules

10:37:26 AM: Installing NPM modules using NPM version 6.4.1

10:37:53 AM: > uglifyjs-webpack-plugin@0.4.6 postinstall 
/opt/build/repo/node_modules/uglifyjs-webpack-plugin

10:37:53 AM: > node lib/post_install.js

10:37:55 AM: npm

10:37:55 AM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):

10:37:55 AM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

10:37:55 AM: added 1280 packages from 735 contributors and audited 12827 
packages in 28.118s

10:37:55 AM: found 0 vulnerabilities

10:37:55 AM: NPM modules installed

10:37:55 AM: Started restoring cached go cache

10:37:55 AM: Finished restoring cached go cache

10:37:55 AM: unset GOOS;

10:37:55 AM: unset GOARCH;

10:37:55 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.10.linux.amd64';

10:37:55 AM: export PATH="/opt/buildhome/.gimme/versions/go1.10.linux.amd64/bin:${PATH}";

10:37:55 AM: go version >&2;

10:37:55 AM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.10.linux.amd64.env';

10:37:55 AM: go version go1.10 linux/amd64

10:37:55 AM: Installing missing commands

10:37:55 AM: Verify run directory

10:37:55 AM: Executing user command: npm run build

10:37:55 AM: > react-blog@0.1.0 build /opt/build/repo

10:37:55 AM: > react-scripts build`enter code here`

10:37:57 AM: Creating an optimized production build...

10:38:02 AM: Failed to compile.

10:38:02 AM: Failed to minify the code from this file:

10:38:02 AM:    ./node_modules/indicative/builds/main.js:1:52673

10:38:02 AM: npm ERR! code ELIFECYCLE

10:38:02 AM: npm ERR! errno 1

10:38:02 AM: npm ERR! react-blog@0.1.0 build: `react-scripts build`

10:38:02 AM: npm ERR! Exit status 1

10:38:02 AM: npm ERR!

10:38:02 AM: npm ERR! Failed at the react-blog@0.1.0 build script.

10:38:02 AM: npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

10:38:02 AM: npm ERR! A complete log of this run can be found in:

10:38:02 AM: npm ERR!     /opt/buildhome/.npm/_logs/2018-09-25T05_08_02_457Z-
debug.log

10:38:02 AM: Caching artifacts

10:38:02 AM: Started saving node modules

10:38:02 AM: Finished saving node modules

10:38:02 AM: Started saving pip cache

10:38:02 AM: Finished saving pip cache

10:38:02 AM: Started saving emacs cask dependencies

10:38:02 AM: Finished saving emacs cask dependencies

10:38:02 AM: Started saving maven dependencies

10:38:02 AM: Finished saving maven dependencies

10:38:02 AM: Started saving boot dependencies

10:38:02 AM: Finished saving boot dependencies

10:38:02 AM: Started saving go dependencies

10:38:02 AM: Finished saving go dependencies

10:38:03 AM: Cached node version v8.12.0

10:38:03 AM: Error running command: Build script returned non-zero exit code: 1

10:38:03 AM: Failing build: Failed to build site

10:38:03 AM: failed during stage 'building site': Build script returned non-zero 
exit code: 1

10:38:03 AM: Finished processing build request in 46.262986678s

Please someone suggest what might have gone wrong here??

The issue here is caused by the build environment using react-scripts in your create-react-app . You have a node_modules package being imported that is in an unexpected bundle format.

When running your npm run build in local development , which is what is happening on Netlify, you will see the following error on your build:

Failed to minify the code from this file:

        ./node_modules/indicative/builds/main.js:1:52673

Read more here: http:// bit.ly/2tRViJ9

As explained in the link ( http:// bit.ly/2tRViJ9 ), react-scripts need to upgrade to react-scripts@>=2.0.0

$ npm install react-scripts@^2.0.0

In the previous version (<2.0.0), react-scripts did not support ES.Next features found in node_modules . It expected CommonJS or ES and recommended to compile to ES5 for older browsers. Now the builds will allow you to Set target browsers and use ES.Next features.

Once you confirm that the build local has no errors you can push these changes to your git repository and your Netlify build should also work.

NOTE: When using Netlify as your CI/CD solution, it is a good practice to make sure to run your build command during local development prior to pushing your changes to your master target branch to make sure there are not any issues with your production build.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM