为什么我的 .gitlab-ci.yml 在纱线测试中一直失败,错误为“/bin/sh: 1: react-scripts: not found”?
Why does my .gitlab-ci.yml keep failing on yarn test with error "/bin/sh: 1: react-scripts: not found"?
这里我有一个使用 npx create-react-app 创建的简单 React 应用程序。
管道成功提取缓存,但在 yarn test --watchAll=false
失败,错误为“/bin/sh: 1: react-scripts: not found”。
我该如何解决这个问题?
React 应用程序位于 src/client 目录中,因此 before_script 到正确的目录中,如下面的 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
引用构建目录,或者在您的 test_react
作业中将其移动到 src/client
。
这里我有一个使用 npx create-react-app 创建的简单 React 应用程序。
管道成功提取缓存,但在 yarn test --watchAll=false
失败,错误为“/bin/sh: 1: react-scripts: not found”。
我该如何解决这个问题?
React 应用程序位于 src/client 目录中,因此 before_script 到正确的目录中,如下面的 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
引用构建目录,或者在您的 test_react
作业中将其移动到 src/client
。