why firebase functions onCall not deploy?


i have typescript code in index.ts

import * as functions from "firebase-functions";
import * as cors from "cors";

cors({ origin: true });

exports.myFunc = functions.https.onCall((data, context) => {
  const { uid } = context.auth;

  return { uid };
});

If i try deploy this function:

firebase deploy --only functions:myFunc

I get back:

functions: the following filters were specified but do not match any functions in the project: myFunc

what am I doing wrong ?

- - Source

Answers

answered 5 day ago Ahmed M.Kamal #1

// index.js

const functions = require('firebase-functions');
const cors = require('cors');

cors({ origin: true });

exports.myFunc = functions.https.onCall((data, context) => {
  const { uid } = context.auth;
  return { uid };
});

then $ firebase deploy --only functions

answered 5 day ago DarkSir #2

i found a mistake. Typescript compile my .js files in directory lib/functions/src/index.js but my package.json file have outher path to main file

{
  ...
  "main": "lib/index.js",
  ...
}

i changed to

{
  ...
  "main": "lib/functions/src/index.js",
  ...
}

and it worked!

comments powered by Disqus