0

I have tried to deploy Firebase Cloud Functions in order to delete users.

but I got an error.

Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module

The source code is below.

(functions/node_modules/index.js)

import functions = require("firebase-functions");
import admin = require("firebase-admin");

// firebase-adminの初期化
admin.initializeApp();

exports.deleteUser = functions
    .region("asia-northeast1")
    .firestore.document("deleted_users/{docId}")
    .onCreate(async (snap, context) => {
      const deleteDocument = snap.data();
      const uid = deleteDocument.uid;

      // Authenticationのユーザーを削除する
      await admin.auth().deleteUser(uid);
    });

Does anyone know why this error happens?

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
user51375
  • 1
  • 2
  • 1
    Try `const` instead of `import` in first 2 lines. – Dharmaraj Jul 08 '22 at 07:35
  • Thank you. I guess It works. but I still have an error" HTTP Error: 403, AccessDeniedAccess denied.
    service-799047667557@gcf-admin-robot.iam.gserviceaccount.com does not have storage.objects.create access to the Google Cloud Storage object.
    "
    – user51375 Jul 08 '22 at 07:43
  • It's still a duplicate: https://stackoverflow.com/questions/51410633/service-account-does-not-have-storage-objects-get-access-for-google-cloud-storag – Martin Zeitler Jul 08 '22 at 07:45

0 Answers0