简体   繁体   English

Netlify 使用 create-react-app (CRA) 网站构建错误

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

Getting: Build script returned non-zero exit code: 1获取:构建脚本返回非零退出代码:1

I have deployed my react js website code through Netlify and getting a build log and error as follows:我已经通过 Netlify 部署了我的 react js 网站代码,并得到了一个构建日志和错误,如下所示:

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 .这里的问题是由在create-react-app使用react-scripts的构建环境引起的。 You have a node_modules package being imported that is in an unexpected bundle format.您正在导入一个node_modules包,该包采用意外的包格式。

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:本地开发中运行npm run build时,这就是 Netlify 上发生的情况,您将在构建中看到以下错误:

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如链接( http://bit.ly/2tRViJ9 )中所述, react-scripts需要升级到 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 .在以前的版本(<2.0.0), react-scripts不支持ES.Next特征发现node_modules It expected CommonJS or ES and recommended to compile to ES5 for older browsers.它期望使用 CommonJS 或 ES,并建议为旧浏览器编译为 ES5。 Now the builds will allow you to Set target browsers and use ES.Next features.现在构建将允许您设置目标浏览器并使用 ES.Next 功能。

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.一旦您确认构建本地没有错误,您就可以将这些更改推送到您的 git 存储库,并且您的 Netlify 构建也应该可以工作。

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.注意:使用 Netlify 作为 CI/CD 解决方案时,在将更改推送到主目标分支之前确保在本地开发期间运行构建命令是一个很好的做法,以确保您的生产构建没有任何问题.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在没有 CRA(create-react-app)的情况下从 react 到 express 获取错误 - Error fetch from react to express without CRA(create-react-app) 反应由 CRA(create-react-app) 创建的 web 总是重定向到 '/' - react web created by CRA(create-react-app) always redirect to '/' 在使用 CRA (create-react-app) 创建的应用程序中,在哪里可以找到 webpack 配置文件 - Where to find webpack config file inside a app created using CRA(create-react-app) 如何在CRA(create-react-app)中对资产进行版本控制? - How to do versioning for assets in a CRA (create-react-app)? Cypress 测试覆盖率(Create-react-app CRA Typescript) - Cypress Test Coverage (Create-react-app CRA Typescript) 如何在没有 create-react-app 的情况下像在 CRA 中一样配置代理? - How to configure a proxy like in CRA without create-react-app? 从 create-react-app (CRA) 转换为 CRA + Next.Js 应用 - Conversion from an create-react-app (CRA) to CRA + Next.Js app 使用带有googleapis的Create-react-app时出错 - Error using Create-react-app with googleapis 解决使用 CRA 时的 JSX 语法错误(创建 React 应用程序) - Resolving JSX syntax error when using CRA (create react app) 在 .netlify 中捕获 create-react-app 的所有重定向 - Catch all redirect for create-react-app in netlify
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM