Apollo iOS:命令/ bin / sh失败,退出代码为1 |命令PhaseScriptExecution失败,退出代码非零

时间:2018-07-03 11:27:00

标签: ios swift apollo apollo-client

我在installation tutorial之后跟随Apollo。而且我完全有信心按照installation tutorial中的描述进行所有操作。但是,在项目的构建过程中,我收到如下编译器错误:

  

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

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生成--schema schema.json --output API.swift

     

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

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失败,退出代码非零

为什么我会收到此错误?

1 个答案:

答案 0 :(得分:5)

花费大量时间并进行搜索后,我理解了为什么会出现错误。向 @NiltiakSivad 提问,以获取对GitHub issue discussion

的回答

Apollo script尝试在项目文件夹中查找带有扩展名 .graphql 的文件,其中包含适当的查询变异。如果它们不存在,则可能会出现上述错误。我认为阿波罗团队应该在安装教程中警告观众这种可能的情况!

因此,为了成功运行项目,请确保:

  • 您的 Apollo版本 apollo-codegen
  • 兼容
  • 您正确添加了Apollo script
  • 您在项目文件夹中有 schema.json
  • 您在项目文件夹中具有扩展名 .graphql 的文件 包含适当的 schema.json 查询变异
相关问题