The keyword 'await' is reserved


#1

Hi,

I recently updated Node version from 6.6.0 to v6.7.0. I’m using Meteor 1.4.1.1 and encountered this error:

   While building for os.linux.x86_64:
   imports/apollo/resolvers.js:53:24: The keyword 'await' is reserved (53:24)

Can someone tell me what might be the problem here?

My code was working earlier but now it fails to build.

Here’s the complete log:

=> Started proxy.                             
=> Errors prevented startup:                  
   
   While processing files with ecmascript (for target web.browser):

   /home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/visitors.js:232:13:
   /imports/apollo/connectors.js: You gave us a visitor for the node type "ForAwaitStatement" but it's not a valid
   type
   at verify
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/visitors.js:232:13)
   at Object.explode
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/visitors.js:95:3)
   at traverse
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/index.js:88:12)
   at NodePath.traverse
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/index.js:156:49)
   at exports.default (/home/projects/chatter/node_modules/babel-helper-remap-async-to-generator/lib/index.js:10:8)
   at PluginPass.Function
   (/home/projects/chatter/node_modules/babel-plugin-transform-async-to-generator/lib/index.js:13:56)
   at newFn
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/visitors.js:310:19)
   at NodePath._call
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/context.js:78:18)
   at NodePath.call
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/context.js:49:17)
   at NodePath.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/context.js:108:12)
   at TraversalContext.visitQueue
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:174:16)
   at TraversalContext.visitSingle
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:124:19)
   at TraversalContext.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:219:19)
   at Function.traverse.node
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/index.js:171:17)
   at NodePath.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/context.js:118:43)
   at TraversalContext.visitQueue
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:174:16)
   at TraversalContext.visitMultiple
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:119:17)
   at TraversalContext.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:217:19)
   at Function.traverse.node
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/index.js:171:17)
   at NodePath.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/path/context.js:118:43)
   at TraversalContext.visitQueue
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:174:16)
   at TraversalContext.visitSingle
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:124:19)
   at TraversalContext.visit
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/context.js:219:19)
   at Function.traverse.node
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/index.js:171:17)
   at traverse
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-traverse/lib/index.js:90:12)
   at File.transform
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-core/lib/transformation/file/index.js:548:35)
   at
   /home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-core/lib/transformation/pipeline.js:73:19
   at File.wrap
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-core/lib/transformation/file/index.js:563:16)
   at Pipeline.transformFromAst
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/babel-core/lib/transformation/pipeline.js:70:17)
   at
   /home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/index.js:60:8
   at Cache.Cp.get
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/cache.js:94:19)
   at Object.compile
   (/home/justauser/.meteor/packages/ecmascript/.0.5.8.8wadz4++os+web.browser+web.cordova/plugin.compile-ecmascript.os/npm/node_modules/meteor/babel-compiler/node_modules/meteor-babel/index.js:47:23)
   at Object.Babel.compile (packages/babel-compiler/babel.js:26:1)
   at packages/babel-compiler/babel-compiler.js:93:1
   at Function.time (/tools/tool-env/profile.js:305:10)
   at profile (packages/babel-compiler/babel-compiler.js:123:1)
   at BabelCompiler.BCp.processOneFileForTarget (packages/babel-compiler/babel-compiler.js:92:1)
   at BabelCompiler.<anonymous> (packages/babel-compiler/babel-compiler.js:21:1)
   at Array.forEach (native)
   at BabelCompiler.BCp.processFilesForTarget (packages/babel-compiler/babel-compiler.js:20:1)
   
   
   While building for os.linux.x86_64:
   imports/apollo/resolvers.js:53:24: The keyword 'await' is reserved (53:24)
   
=> Your application has errors. Waiting for file change.

Please help.


Error: The keyword 'await' is reserved
#2

New version of Babel compiler implements async / await keywords from ES7 stage 3 proposal. Therefore these keywords are now reserved. You probably use a variable called await in your code, which breaks the compiler. Simply rename the variable and you’ll be fine.


#3

Not using “await” as a var anywhere in my code, and getting same error, even in the same file! Apollo people, what’s up with this?


#4

So I guess deleting my .babelrc is the answer. But doesn’t that seem strange? It works, so I guess I can’t complain :smiley:


#5

It seems that if you have babel-plugin-transform-async-to-generator somewhere in your .babelrc (in plugins list or as a part of a preset) the meteor build fails. At least for me removing those solved the issue.


#6

I’ve just struck the same trouble. I think it’s a problem with Meteor’s emacscript package and some recent change in Babel. Our code uses async / await and was working in Meteor no problem. One of our developers hit it first, I wasn’t having the problem so to see if I could replicate it I wiped my node_modules and meteor npm install. Then the problem appeared. So presumably an updated packages is part of the cause.

But I don’t think it’s Babel because I also use WallabyJS across the project and it can compile and run the project fine (using the same node_modules and .babelrc), including the async / await statements. So the difference is the Meteor compiler.

I’ve tried pinning all the babel packages I import back to the old versions but that doesn’t fix it. So it’s probably some babel package depended on by another module. I’m not sure how to proceed from here but I love async / await and would hate to have to give them up.


#7

Thanks for the help guys. In my case, it was a conflict between meteor’s ecmascript package and the babelrc file. My solution was to only run babelrc during test or running storybook.


#8

I had the same problem. I solved it by removing the stage-2 preset which was updated recently.


#9

For reference:

https://github.com/meteor/meteor/issues/7897