Help us understand the problem. What is going on with this article?

AWS Amplify API作成

amplify push をしたらエラーが発生。
この記事を参考に問題を解決しました。

しかし、amplify add apiで別のエラーに引っかかる。

MacBook-Air:ampIAM ****$ amplify add api
? Please select from one of the below mentioned services: GraphQL
SyntaxError: Unexpected identifier
    at serviceQuestions (/Users/******/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/provider-utils/awscloudformation/index.js:13:10)
    at Object.addResource (/Users/******/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/provider-utils/awscloudformation/index.js:54:10)
    at /Users/******/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/commands/api/add.js:24:35
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
    at async Object.executeAmplifyCommand (/Users/******/.npm-global/lib/node_modules/@aws-amplify/cli/node_modules/amplify-category-api/index.js:176:3)
There was an error adding the API resource

とのことなので、とりあえずNode.jsの更新を行います。

$ npm install -g n
$ n --stable
$ n --latest
$ n latest

sudoを求められた場合は、npm install -g nの実行結果にあるnのフルパスを使って下記のように書くと実行できます。

sudo フルパス latest

再度apiを作成。

✔ Generated GraphQL operations successfully and saved at graphql
✔ Code generated successfully and saved in file API.swift
✔ All resources are updated in the cloud

うまくいきました!

@aws-amplify/cliのアップデートを行った際は、対応のバージョンにnpm及びNode.jsのアップデートが必要になるようです。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした