AWS Amplify 构建错误 – 在模式中找到不匹配的括号

huangapple go评论72阅读模式
英文:

AWS Amplify Build Error - Mismatched Brackets Found In The Schema

问题

End Desire:

构建我的AWS Amplify项目在dev环境中,使用全栈CI/CD。例如,将我的更改推送到Code Commit将构建后端资源。

Build Logs:

2023-01-06T06:19:26.457Z [INFO]: [33m注意:建议从您的应用程序目录的根目录运行此命令[39m
2023-01-06T06:19:27.797Z [WARNING]: - 初始化您的环境:dev
2023-01-06T06:19:29.164Z [WARNING]: - 构建资源api/project
2023-01-06T06:19:33.756Z [WARNING]: - 构建资源auth/project
2023-01-06T06:19:33.902Z [WARNING]: - 构建资源storage/project
2023-01-06T06:19:33.939Z [WARNING]: ✔ 成功初始化提供程序。
2023-01-06T06:19:34.452Z [WARNING]: ✖ 初始化您的环境时出现错误。
2023-01-06T06:19:34.453Z [INFO]: 🛑 语法错误:在模式中找到不匹配的括号。在模式中第239行发现了意外的)。
2023-01-06T06:19:34.453Z [INFO]: 了解更多信息:https://docs.amplify.aws/cli/project/troubleshooting/

buildspec.yml:

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - npm i
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Checks:

  1. 我已检查了graphql.schema中的错误。
  2. 我已删除了buildspec中的测试部分。
  3. 我已根据此处的建议添加了amplify push --simple
  4. 我已成功在本地CLI上运行了npm run build
英文:

End Desire:

To build my AWS Amplify project in the dev environment, using full-stack CI/CD. So for example, pushing my changes to Code Commit will build the backend resources.

Build Logs:

2023-01-06T06:19:26.457Z [INFO]: [33mNote: It is recommended to run this command from the root of your app directory[39m
2023-01-06T06:19:27.797Z [WARNING]: - Initializing your environment: dev
2023-01-06T06:19:29.164Z [WARNING]: - Building resource api/project
2023-01-06T06:19:33.756Z [WARNING]: - Building resource auth/project
2023-01-06T06:19:33.902Z [WARNING]: - Building resource storage/project
2023-01-06T06:19:33.939Z [WARNING]: ✔ Initialized provider successfully.
2023-01-06T06:19:34.452Z [WARNING]: ✖ There was an error initializing your environment.
2023-01-06T06:19:34.453Z [INFO]: 🛑 Syntax Error: mismatched brackets found in the schema. Unexpected ) at line 239 in the schema.
2023-01-06T06:19:34.453Z [INFO]: Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

buildspec.yml:

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - npm i
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: .next
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Checks:

  1. I have checked the graphql.schema for errors.
  2. I have removed the testing section in the buildspec.
  3. I have added amplify push --simple as recommended here
  4. I've ran npm run build on my local CLI successfully

答案1

得分: 0

在AWS Amplify控制台中,在构建设置下,AWS CLI版本为"latest"。将AWS CLI版本更改为10.4.0解决了该问题。

在此查看AWS CLI版本:https://www.npmjs.com/package/@aws-amplify/cli?activeTab=versions

不要选择10.4.0,而是选择在最新AWS CLI版本发布之前的几个版本。

英文:

In the AWS Amplify console, under build settings, the AWS CLI version was "latest". Changing the AWS CLI version to 10.4.0 fixed the issue.

View AWS CLI Versioning here: https://www.npmjs.com/package/@aws-amplify/cli?activeTab=versions

Rather than going to 10.4.0, go back a couple versions from the latest AWS CLI version at the time.

答案2

得分: 0

这可能与GitHub上的此问题相关。Amplify(意外地)解析了包含实际查询、变更和类型的GraphQL注释,并将其报告为语法错误。

根据GitHub问题,已在v10.6.2中修复。

英文:

This is probably related to this issue on GitHub. Amplify did (accidentally) parse GraphQL comments that contain actual queries, mutations and types and reported these as syntax error.

It has been fixed in v10.6.2 according to the GitHub issue.

huangapple
  • 本文由 发表于 2023年1月6日 14:41:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/75027759.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定