continuous-integration - 为什么我的 .gitlab-ci.yml 在纱线测试中不断失败,并出现错误“/bin/sh: 1: react-scripts: not found”?
问题描述
在这里,我有一个使用 npx create-react-app 创建的简单反应应用程序。
管道成功提取缓存但失败yarn test --watchAll=false
并出现错误“/bin/sh: 1: react-scripts: not found”。
我该如何解决?。
react 应用程序位于 src/client 目录中,因此 before_script 到 cd 在正确的目录中,如下面的 yml 文件所示。
.gitlab-ci.yml:
image: node:latest
default:
before_script:
- cd src/client
stages:
- build
- test
cache:
paths:
- node_modules/
build_react:
stage: build
script:
- yarn install
- yarn build
artifacts:
expire_in: 1 hour
paths:
- build
test_react:
stage: test
script:
- pwd
- yarn test --watchAll=false
解决方案
在运行任何脚本之前下载并提取工件,因此它将被提取到{project_root}/
,然后您的默认 before_script 将运行。您应该能够通过 引用构建目录../../build
,或将其移动到src/client
您的test_react
工作中。
推荐阅读
- python - 为什么只有在不修复 HDF5 弃用警告时才能处理大文件?
- python - 添加零以使所有子集大小相同,然后将它们相加并在 Excel 中显示
- javascript - 数组中的答案不能消失
- python - Python结合了多个相似的功能
- java - 如何在字符串中复制反斜杠字符?
- python - AppRegistryNotReady:应用尚未加载
- python - 如何仅检查文件夹内的文件夹?
- string - 如何使字符串向后移动每个字母
- python - 我怎样才能加快这个“for”循环?
- python-3.x - 如何在 python 环境的 atom 编辑器中为自定义导入的模块启用自动完成功能?