Does Glitch support async functions


#1

Hello everyone,

Does Glitch allows async functions? I tried for the 1st time today, and when launching index.js in the terminal, I got the following error message:

async function countUrls() {
      ^^^^^^^^
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.runMain (module.js:611:10)
    at run (bootstrap_node.js:387:7)
    at startup (bootstrap_node.js:153:9)

Thank you!
Ed


#2

Yes, for example https://glitch.com/edit/#!/async-await-playground. Perhaps check which version of Node your app is using in package.json - it’ll need to be Node 7.6 up for async.


#3

Thank you @Gareth ! This worked. I added the following in package.json:

  "engines": {
    "node": "8.x"
  }

Ed