amazon-archives / awsmobile-cli

CLI experience for Frontend developers in the JavaScript ecosystem.
Apache License 2.0
142 stars 35 forks source link

Error when running awsmobile init #77

Closed jerwallace closed 6 years ago

jerwallace commented 6 years ago

Was following the guide here: https://docs.aws.amazon.com/aws-mobile/latest/developerguide/web-getting-started.html

Created a sample app: https://reactjs.org/blog/2016/07/22/create-apps-with-no-configuration.html

Then ran the init line: awsmobile init

The following response was given:

/usr/local/lib/node_modules/awsmobile-cli/lib/init-steps/s2-choose-strategy.js:104
async function inquirerForValid(initInfo){
      ^^^^^^^^
SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/local/lib/node_modules/awsmobile-cli/lib/command-init.js:16:24)
Gribbs commented 6 years ago

You sure it’s not your Node version? I just had the same error trying to run code using async/await on Lambda. The Nodejs runtime was too old on Lambda for async functions. If using Mac, try: brew update brew upgrade node

m-bymike commented 6 years ago

Hi @jerwallace , you probably had the same issue as I did. I proposed a fix in #78 . Until it's accepted and released, you can clone my fork, run npm install and runt the command directly from the local repo path/to/repo/bin/awsmobile init...

UnleashedMind commented 6 years ago

This is a bug @m-bymike Thanks for the contribution, your pull request has been merged. The bug fix has been published to the latest version v1.0.21

UnleashedMind commented 6 years ago

close this issue for now, feel free to re-open it if you still see the same problem

kravenoff42 commented 6 years ago

Just ran into the exact same issue

ec2-user:~/environment/portfolio $ awsmobile init [project ID]                                                                                                                           

/home/ec2-user/.nvm/versions/node/v6.13.0/lib/node_modules/awsmobile-cli/lib/init-steps/s2-choose-strategy.js:104
async function inquirerForValid(initInfo){
      ^^^^^^^^

SyntaxError: Unexpected token function
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ec2-user/.nvm/versions/node/v6.13.0/lib/node_modules/awsmobile-cli/lib/command-init.js:16:24)

Here are the versions I've got:

npm v3.10.10 Node v6.13.0 create-react-app v1.5.2 awsmobile-cli 1.0.21

let me know if there any other info I can get you to help

UnleashedMind commented 6 years ago

We obviously mixed two issues here. One issue is a bug that has already been fix by the latest release v1.0.21 The other issue is because the node version is too old, and it does not support the async/await syntax. We suggest to use node version 8 and above.

luisoutofoffice commented 6 years ago

I used the latest version of Node and I still ran into the problem 😞

EDIT: Okay, using sudo awsmobile init did the trick.