I’m trying to follow this documentation to use parameterized configuration in my Firebase cloud functions.
The example they give is in Javascript, in particular in how they import defineInt
and defineString
from firebase-functions/params
.
const { defineInt, defineString } = require('firebase-functions/params');
But all my functions code is in Typescript so I tried to translate that into:
import {defineInt} from "firebase-functions/lib/params";
Since apparently firebase-functions/params
cannot be resolved.
But then when I try to deploy my functions, I get the following error message:
Error: Failed to load function definition from source: Failed to
generate manifest from function source: Error
[ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./lib/params’ is not
defined by "exports" in
/Users/sarbogast/dev/blindly/blindly/functions/node_modules/firebase-functions/package.json
Any idea what’s the proper way to import those functions in Typescript?
2
Answers
The following import should resolve the issue:
Dependencies:
And given that the error is an
eslint
one and it doesn’t make sense in that context, adding the following to.eslintrc.js
turns the blocking error into a more persmissive warning:I was having the same issue with the following firebase functions SDK (node: 16.x.x)
I changed how I imported the
defineSecret
and it’s now working. I didn’t have to change the.eslintrc
either