【问题标题】:Apollo iOS: Command /bin/sh failed with exit code 1 | Command PhaseScriptExecution failed with a nonzero exit codeApollo iOS:命令 /bin/sh 失败,退出代码 1 |命令 PhaseScriptExecution 失败,退出代码非零
【发布时间】:2018-12-11 16:50:28
【问题描述】:

我通过Apollo 跟踪installation tutorial。我完全相信我按照installation tutorial 中的描述做了所有事情。但是,在构建项目期间,我收到了如下编译器错误:

TypeError: 无法读取未定义的属性“长度”

at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:186:17)
at Object.runCommand (/usr/local/lib/node_modules/apollo- codegen/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:1013:30)
at Object.get [as argv] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/usr/local/lib/node_modules/apollo-codegen/lib/cli.js:197:5)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)

命令 /bin/sh 失败,退出代码为 1

++ exec apollo-codegen generate --schema schema.json --output API.swift

TypeError: 无法读取未定义的属性“长度”

at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:186:17)
at Object.runCommand (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:1013:30)
at Object.get [as argv] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/usr/local/lib/node_modules/apollo-codegen/lib/cli.js:197:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)

命令 PhaseScriptExecution 失败,退出代码非零

为什么我会收到此错误?

【问题讨论】:

    标签: ios swift apollo apollo-client


    【解决方案1】:

    在花了很多时间并进行了搜索之后,我明白了为什么会出现错误。感谢 @NiltiakSivadGitHub issue discussion 上的回答

    Apollo script 试图在具有适当 查询mutations 的项目文件夹中查找扩展名为 .graphql 的文件。如果它们不存在,您可能会出现上述错误。我认为 Apollo 团队应该在安装教程中警告他们的观众这种可能的情况!

    所以,为了成功运行项目,请确保:

    • 您的 Apollo 版本apollo-codegen 兼容
    • 您正确添加Apollo script
    • 您的项目文件夹中有 schema.json
    • 您在项目文件夹中有扩展名为 .graphql 的文件 包含适合您的 schema.json querymutation

    【讨论】:

    • 能否请您解释一下如何确认 Apollo 版本与 apollo-codegen 兼容
    • 当您将编译项目并收到错误消息时,您应该会在 Xcode 的构建输出日志中看到这一点。不记得错误是什么样子的,但它会类似于“您使用apollo-codegen0.18.x 版本,但需要0.16.x”。此外,您可以在此处找到更多信息:github.com/apollographql/apollo-ios/issues
    猜你喜欢
    • 2020-10-25
    • 2021-04-30
    • 2020-06-27
    • 2020-12-18
    • 1970-01-01
    • 2021-02-03
    • 2019-07-23
    • 1970-01-01
    • 2022-01-14
    相关资源
    最近更新 更多