2017-10-16 13 views
1

私はNode.jsのV8.3.0を持っている、と私のpackage.jsonでこれを持っている:Firebase非同期関数の構文エラー

"engines": { 
    "node": ">=8.3.0" 
    } 

とのawait /非同期のための私のテストコード:予想

async function x() { 
    return "test"; 
} 

exports.asyncTest = functions.https.onRequest((request, response) => async function() { 
    response.end(await x()); 
}); 

出力:test
観測出力:

Is there a syntax error in your code? 
Detailed stack trace: /user_code/index.js:12 
async function x() { 
     ^^^^^^^^ 
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 getUserFunction (/var/tmp/worker/worker.js:372:24) 

答えて

3

クラウド機能についてFirebaseランタイムは現在Node.js v6.xです。したがって、async/awaitはサポートされていません。ノードv8.xは、長期サポート(LTS)に入った後でいつでもサポートされる予定です。一方

は、あなたが非同期を利用するためにバベルや活字体のようなtranspilerを使用する必要があります/待っています。

+2

はFYI:わからないこれをdownvoted人が、それは正解です。私はFirebaserで、Cloud Functionsチームと緊密に連携しています。 –

+0

情報をお寄せいただきありがとうございます。あなたはいつv7.6をサポートする予定ですか? –

+2

私たちは、今後の作業のための具体的なスケジュールを発表していないが、(Node.jsのV8エンジンは、LTSを行くときである)10月31日の後にいつかなります。 –

関連する問題