【问题标题】:How import firebase cloud function config dynamically in NodeJS 14 with `type: module`? [ closed ]如何使用`type:module`在NodeJS 14中动态导入firebase云功能配置? [关闭]
【发布时间】:2022-01-31 16:44:45
【问题描述】:

我想实现动态导入云功能配置,但它不会按预期工作。

import config from "firebase-functions";

它有效✔️

const {config} = await import('firebase-functions');

它不会工作❌

也尝试了以下方法,但不起作用。

import * as functions from "firebase-functions"; // function is already using as static import
or 
const functions = await import('firebase-functions');
functions.config ❌// => undefined
functions.auth ✔️
functions.firestore ✔️
//and analytics, app, auth, database, firestore, handler, https, pubsub, remoteConfig, storage, testLab, logger ✔️

我没有办法将配置导入与函数一起动态导入。

【问题讨论】:

    标签: node.js firebase google-cloud-functions node-modules


    【解决方案1】:

    哦,终于成功了。

    const { default: functions} = await import('firebase-functions');
    

    import functions from "firebase-functions";
    

    给函数.config

    【讨论】:

      猜你喜欢
      • 2018-11-22
      • 1970-01-01
      • 2022-01-24
      • 1970-01-01
      • 2021-03-10
      • 2021-10-10
      • 2020-04-27
      • 2021-06-04
      • 1970-01-01
      相关资源
      最近更新 更多