简体   繁体   English

如何修复 yarn serve -s build 给出的错误

[英]How do I fix this error given by yarn serve -s build

I'm using GitHub actions to run my cypress tests automatically on every commit.我正在使用 GitHub 操作在每次提交时自动运行我的 cypress 测试。 This is the part of code in my yml file which was working earlier:这是我之前工作的 yml 文件中的代码部分:

with:
  browser: chrome
  build: yarn run build
  start: yarn start
  wait-on: 'http://localhost:3000'

Then to use serve I made changes in 2 lines:然后使用serve我在 2 行中进行了更改:

with:
  browser: chrome
  run: yarn global add serve //added this line
  build: yarn run build
  start: yarn serve -s build //changed this line
  wait-on: 'http://localhost:3000'

Now instead of running the test, it shows this error:现在它没有运行测试,而是显示了这个错误:

Warning: Unexpected input(s) 'run', valid inputs are ['record', 'config', 'config-file', 'env', 'browser', 'command', 'start', 'start-windows', 'build', 'install', 'install-command', 'runTests', 'wait-on', 'wait-on-timeout', 'parallel', 'group', 'tag', 'working-directory', 'headed', 'spec', 'project', 'command-prefix', 'ci-build-id', 'cache-key', 'quiet', 'component']警告:意外输入“运行”,有效输入为 ['record'、'config'、'config-file'、'env'、'browser'、'command'、'start'、'start-windows' , 'build', 'install', 'install-command', 'runTests', 'wait-on', 'wait-on-timeout', 'parallel', 'group', 'tag', 'working-directory' , 'headed', 'spec', 'project', 'command-prefix', 'ci-build-id', 'cache-key', 'quiet', 'component']

& &

Error: Unable to locate executable file: serve.错误:无法找到可执行文件:服务。 Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable.请验证文件路径是否存在,或者是否可以在 PATH 环境变量指定的目录中找到该文件。 Also check the file mode to verify the file is executable.还要检查文件模式以验证文件是否可执行。

So how do I fix this?那么我该如何解决呢?

Also if I use start: npx serve -s build instead of yarn serve -s build , it works but it is a yarn project and I think I'm not suppose to use npm and npx in yarn projects, right?另外,如果我使用start: npx serve -s build而不是yarn serve -s build ,它可以工作,但它是一个 yarn 项目,我认为我不应该在 yarn 项目中使用 npm 和 npx,对吗? Or can I?或者我可以吗?

with:
  browser: chrome
  build: yarn run build
  start: yarn serve
  wait-on: 'http://localhost:3000'

in package.jsonpackage.json

{
  "scripts": {
    "serve": "serve -s build"
  }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM