gpt4 book ai didi

firebase - 使用 es6 import 语句的 Firebase Cloud Functions

转载 作者:行者123 更新时间:2023-12-02 18:44:14 24 4
gpt4 key购买 nike

有没有办法在 Cloud Functions for Firebase 中使用 es6 语法?

import functions from 'firebase-functions';

export const helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
})

失败:

SyntaxError: Unexpected token import

最佳答案

简短的回答是,不,你还不能这样做。和云函数没有任何关系。和节点有关系。如果您使用命令 node index.js 将节点指向 index.js,您将看到完全相同的错误。

关于为什么这是一个复杂问题的长答案已经在一些博客中讨论过,例如 herehere .

编辑:firebase CLI now supports projects using TypeScript ,它使您可以访问 ES7 语法。它将自动编译为 ES6 以部署到 Cloud Functions。

关于firebase - 使用 es6 import 语句的 Firebase Cloud Functions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42739539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com