Heroku 持续集成 (CI) 无法构建 react-scripts

问题描述

我有一个 TypeScript 和 React 应用程序,我想向其中添加持续集成,所以我在“设置”下启用了我的管道。

当我提交到我的主分支时,heroku 应用程序的构建成功,但测试失败,见 (pipeline name) > Tests。我已经包含了以下两者的日志。您可以对它们进行比较,并看到它们几乎完全相同,只是测试必须自动检测 buildpack、纱线缓存和一些环境变量。

这些是否有可能导致构建失败?我的测试应该有什么不同?

production succeeds

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       

-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       

-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.16.0...
       Using default npm version: 6.14.11
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.10)
       Installed yarn 1.22.10
       
-----> Restoring cache
       - yarn cache
       
-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.10
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.3.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       Done in 10.02s.
       
-----> Build
       Running heroku-postbuild (yarn)
       yarn run v1.22.10
       $ yarn compile-tsc && cd client && yarn && yarn run build
       $ tsc
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.3.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       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.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       $ react-scripts build
       Creating an optimized production build...
       Compiled successfully.
       
       File sizes after gzip:
       
         127.33 KB  build/static/js/2.a700b678.chunk.js
         1.88 KB    build/static/js/main.24b36bd5.chunk.js
         773 B      build/static/js/runtime-main.900dd88b.js
         547 B      build/static/css/main.68ae183e.chunk.css
       
       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.
       You may serve it with a static server:
       
         yarn global add serve
         serve -s build
       
       Find out more about deployment here:
       
         https://cra.link/deployment
       
       Done in 80.63s.
tests fail

-----> Building on the Heroku-20 stack
-----> Auto detecting buildpacks...
       buildpack detected
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_PRODUCTION=false
       NPM_CONFIG_LOGLEVEL=error
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=test
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       engines.yarn (package.json):  unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.16.0...
       Using default npm version: 6.14.11
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.10)
       Installed yarn 1.22.10
       



-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.10
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.3.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       Done in 38.82s.
       
-----> Build
       Running heroku-postbuild (yarn)
       yarn run v1.22.10
       $ yarn compile-tsc && cd client && yarn && yarn run build
       $ tsc
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@2.3.2: The platform "linux" is incompatible with this module.
       info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
       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.
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       $ react-scripts build
       Creating an optimized production build...
       Failed to compile.
       
       src/App.tsx
       Syntax error: Unexpected token (21:9)
       
       > 21 |     lobbyId!: string;
            |            ^
       
       
       src/models-shared.ts
       Syntax error: Unexpected token,expected "{" (5:8)
       
         3 | import cookie from 'react-cookies'
         4 |
       > 5 | export namespace Const
           |        ^
         6 | {
         7 |      export const UniqueIdLength = 8;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...