Amplify-cli: Amplify CLI is not behaving as in the docs; push, codegen don't work

Created on 6 Sep 2018  路  8Comments  路  Source: aws-amplify/amplify-cli

* Which Category is your question related to? *
Graphql API

* What AWS Services are you utilizing? *
AWS Appsync

* Provide additional details e.g. code snippets *
Amplify CLI is not behaving as expected from the docs.
Platform: Windows 10

Simply doing amplify push after initializing gives this, and _no Appsync API or DynamoDB tables are being generated in the admin console:_

| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |
? Are you sure you want to continue? true
- Updating resources in the cloud. This may take a few minutes...
GraphQL schema compiled successfully. Edit your schema at ...

Also, if I change the schema.graphql file in amplify/backend/api/YOUR-API-NAME/schema.graphql file to the following, amplify push again doesn't recognize the changes, and again shows the same blank diff output as pasted above:

type Blog @model {
  id: ID!
  name: String!
  owner: User! @connection(name: "UserBlogs")
  posts: [Post] @connection(name: "BlogPosts")
}
type Post @model {
  id: ID!
  title: String!
  blog: Blog @connection(name: "BlogPosts")
  comments: [Comment] @connection(name: "PostComments")
}
type Comment @model {
  id: ID!
  content: String
  post: Post @connection(name: "PostComments")
}
# added User type model
type User @model {
  id: ID!
  name: String!
  blogs: [Blog!]! @connection(name: "UserBlogs")
}

Doing amplify push after this:

| Category | Resource name | Operation | Provider plugin |
| -------- | ------------- | --------- | --------------- |
? Are you sure you want to continue? true
- Updating resources in the cloud. This may take a few minutes...
GraphQL schema compiled successfully. Edit your schema at...

Lastly, amplify codegen add gives this, and no output, or further information:

[[LOGO]]
amplify codegen <subcommand>

  generate    Generate API code or type annotations based on a GraphQL schema and query documents.
              If you want to download schema before generating code pass --download flag
  add         Generate API code or type annotations based on a GraphQL schema and query documents
  configure   Change/Update codegen configuration

_QUESTION: What am I doing wrong here, or plainly missing in the docs?_

All 8 comments

@devautor Are you using windows OS?

@kaustavghosh06 Yes, should have mentioned that (updated)!

@devautor Please use Windows Linux System to run the CLI on windows OS as recommended in the main Readme of the repo.

@kaustavghosh06 Sorry for missing that; in retrospect I had read and forgotten that!
Have no prior experience with it, is this it: https://docs.microsoft.com/en-us/windows/wsl/install-win10. Help is really really appreciated :)

@devautor Yes, you鈥檝e got the right link.

Thank you so much for helping in so swiftly. I hope it will work, and i will update the comment as such to mention it! Thanks :)

@kaustavghosh06 Now that I am using amplify-cli from linux subsystem bash, I am getting this error on doing wsl amplify status:

| Category | Resource name | Operation | Provider plugin   |
| -------- | ------------- | --------- | ----------------- |
| Api      | webreact      | Create    | awscloudformation |
/usr/lib/node_modules/@aws-amplify/cli/node_modules/gluegun/build/index.js:13
    throw up;
    ^

Error: Cannot find module 'C:\Users\gaurav\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules\amplify-provider-awscloudformation'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.keys.forEach (/usr/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/show-helpful-provider-links.js:13:26)
    at Array.forEach (<anonymous>)
    at Object.showHelpfulProviderLinks (/usr/lib/node_modules/@aws-amplify/cli/src/extensions/amplify-helpers/show-helpful-provider-links.js:12:26)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:695:11)

In Windows file explorer, I can confirm that this directory C:\Users\gaurav\AppData\Roaming\npm\node_modules\@aws-amplify\cli\node_modules exists.

I have tried _reinstalling amplify-cli on bash, it doesn't help_.

Note that I am using bash from an amplify project directory that was already created using Windows CLI. Do I need to create a new project through bash only, or is something else wrong?

UPDATE: Push is working now. What I did was these steps:

$ create-react-app web-project
$ cd web-project
/web-project$ bash
/web-project$  npm install -g @aws-amplify/cli     ## Had to do a clean uninstall of previous tries
/web-project$ amplify configure    ## followed instructions
/web-project$ amplify init     ## and magic...

This was apparently not tough; info to help any wanderer.

@devautor Looks like you got it running. And yes, we鈥檒l be adding more documentation for windows. Thanks for the feeedback.

Was this page helpful?
0 / 5 - 0 ratings