Giovanni Lobitos
Giovanni Lobitos

Reputation: 852

Babel: "The keyword 'await' is reserved (53:24)"

We're using async/await for our Meteor project. This syntax is everywhere in our resolvers.js. Everything has been working fine until we've upgraded to Node 6.7. Now it shows this error every time we try to build it:

"The keyword 'await' is reserved (53:24)"

enter image description here

Does anyone know how to solve this?

Here is the content of my .babelrc file:

{
  "presets": ["es2015", "stage-2", "react"],
  "plugins": ["react-require", "babel-root-slash-import"]
}

Upvotes: 9

Views: 9945

Answers (3)

Julio Sampaio
Julio Sampaio

Reputation: 177

Await alone is invalid syntax. await needs to be called inside an async function like:

var aFunction = async function() {
  let aResponse = await get('aValue');
}

Upvotes: 1

chookie
chookie

Reputation: 461

Just in case anyone else searches for this same issue, in my case it was user error, me. I forgot to put the async keyword before the function name.enter image description here

Upvotes: 25

Giovanni Lobitos
Giovanni Lobitos

Reputation: 852

Okay, I found out a solution to my own problem. I just excluded the .babelrc when doing a Meteor build since Meteor already has a package that supports ES6 syntax. I didn't totally remove the .babelrc because I will be needing it on tests and when running the Storybook which does not trigger a Meteor build.

Upvotes: 1

Related Questions