由于未知原因,AWS Amplify React Site的构建失败



TL;DR:我不知道为什么我的React应用程序在AWS Amplify上构建失败。

你好!我是AWS Amplify的新手,需要一些帮助来解开以下日志的神秘面纱。

# Starting phase: preBuild
# Executing command: yarn install
2020-09-14T02:09:01.005Z [INFO]: yarn install v1.16.0
2020-09-14T02:09:01.102Z [INFO]: [1/4] Resolving packages...
2020-09-14T02:09:01.572Z [INFO]: [2/4] Fetching packages...
2020-09-14T02:09:16.267Z [INFO]: info fsevents@2.1.2: The platform "linux" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
2020-09-14T02:09:16.275Z [INFO]: info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
2020-09-14T02:09:16.276Z [INFO]: info fsevents@2.1.3: The platform "linux" is incompatible with this module.
2020-09-14T02:09:16.278Z [INFO]: info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
2020-09-14T02:09:16.284Z [INFO]: [3/4] Linking dependencies...
2020-09-14T02:09:16.286Z [WARNING]: warning " > react-bootstrap-switch@15.5.3" has unmet peer dependency "prop-types@^15.5.0".
2020-09-14T02:09:23.129Z [INFO]: [4/4] Building fresh packages...
2020-09-14T02:09:25.051Z [INFO]: Done in 24.05s.
2020-09-14T02:09:25.072Z [INFO]: # Completed phase: preBuild
2020-09-14T02:09:25.073Z [INFO]: # Starting phase: build
# Executing command: yarn run build
2020-09-14T02:09:25.229Z [INFO]: yarn run v1.16.0
2020-09-14T02:09:25.257Z [INFO]: $ react-scripts build && gulp licenses
2020-09-14T02:09:26.114Z [INFO]: Creating an optimized production build...
2020-09-14T02:09:40.526Z [INFO]: Compiled successfully.
2020-09-14T02:09:40.527Z [INFO]: File sizes after gzip:
2020-09-14T02:09:40.550Z [INFO]: 57.07 KB  build/static/js/2.57db696b.chunk.js
2020-09-14T02:09:40.552Z [INFO]: 46.8 KB   build/static/css/main.b7a04f59.chunk.css
5.82 KB   build/static/js/main.34e0f1c3.chunk.js
779 B     build/static/js/runtime-main.58837106.js
The project was built assuming it is hosted at ./.
You can control this with the homepage field in your package.json.
The build folder is ready to be deployed.
Find out more about deployment here:
bit.ly/CRA-deploy
2020-09-14T02:09:40.864Z [INFO]: [02:09:40]
2020-09-14T02:09:40.864Z [INFO]: Using gulpfile /codebuild/output/src019925290/src/harsh_electronics_site/gulpfile.js
2020-09-14T02:09:40.865Z [INFO]: [02:09:40]
2020-09-14T02:09:40.866Z [INFO]: Starting 'licenses'...
2020-09-14T02:09:40.876Z [INFO]: [02:09:40]
2020-09-14T02:09:40.876Z [INFO]: Finished 'licenses' after 10 ms
2020-09-14T02:09:40.903Z [INFO]: Done in 15.68s.
2020-09-14T02:09:40.907Z [INFO]: # Executing command: node ./node_modules/gulp/bin/gulp.js
2020-09-14T02:09:41.148Z [INFO]: [02:09:41]
2020-09-14T02:09:41.149Z [INFO]: Using gulpfile /codebuild/output/src019925290/src/harsh_electronics_site/gulpfile.js
2020-09-14T02:09:41.149Z [WARNING]: [02:09:41]
2020-09-14T02:09:41.149Z [WARNING]: Task never defined: default
[02:09:41] To list available tasks, try running: gulp --tasks
2020-09-14T02:09:41.153Z [ERROR]: !!! Build failed
2020-09-14T02:09:41.153Z [ERROR]: !!! Non-Zero Exit Code detected
2020-09-14T02:09:41.154Z [INFO]: # Starting environment caching...
2020-09-14T02:09:41.154Z [INFO]: # Environment caching completed
Terminating logging...

仅有的两条错误线几乎出现在最后,但我无法立即确定原因。React站点使用yarn start在我的本地计算机上加载得很好,而且我也没有看到yarn build在本地出现任何故障。有什么想法吗?

如果有帮助的话,下面是gullfile.js:

const gulp = require("gulp");
const gap = require("gulp-append-prepend");
gulp.task("licenses", async function () {
// this is to add Creative Tim licenses in the production mode for the minified js
gulp
.src("build/static/js/*chunk.js", { base: "./" })
.pipe(
gap.prependText(`/*!
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/`)
)
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production mode for the minified html
gulp
.src("build/index.html", { base: "./" })
.pipe(
gap.prependText(`<!--
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->`)
)
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production mode for the minified css
gulp
.src("build/static/css/*chunk.css", { base: "./" })
.pipe(
gap.prependText(`/*!
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/`)
)
.pipe(gulp.dest("./", { overwrite: true }));
return;
});

将gulpfile修改为这样。我刚刚为default任务添加了一个别名。

const gulp = require("gulp");
const gap = require("gulp-append-prepend");
async function license() {
// this is to add Creative Tim licenses in the production mode for the minified js
gulp
.src("build/static/js/*chunk.js", { base: "./" })
.pipe(
gap.prependText(`/*!
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/`)
)
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production mode for the minified html
gulp
.src("build/index.html", { base: "./" })
.pipe(
gap.prependText(`<!--
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-->`)
)
.pipe(gulp.dest("./", { overwrite: true }));
// this is to add Creative Tim licenses in the production mode for the minified css
gulp
.src("build/static/css/*chunk.css", { base: "./" })
.pipe(
gap.prependText(`/*!
=========================================================
* Paper Kit React - v1.2.0
=========================================================
* Product Page: https://www.creative-tim.com/product/paper-kit-react
* Copyright 2020 Creative Tim (http://www.creative-tim.com)
* Coded by HarshElectronics
=========================================================
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/`)
)
.pipe(gulp.dest("./", { overwrite: true }));
return;
}
gulp.task("licenses", license);
gulp.task("default", license);

最新更新