I'm trying to update to the most recent versions of firebase-admin
(11.0.0) and firebase-functions
(3.21.2). I'm using firebase-tools
11.1.0. I get this error when try to deploy my functions:
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib' is not defined by "exports" in /Users/myuser/Documents/myproject/node_modules/firebase-functions/package.json
I've seen similar errors in StackOverflow like this one or this one but this error is slightly different. The problem is not in firebase
or firebase-admin
dependencies but with firebase-functions
.
Using firebase-functions
3.14.1 works (I get some warnings though) but I'd like to update to the latest version so I can hopefully get rid of warnings and get the latest updates.
How can I fix this?
Thanks!
As the error described, the problem was that I had imports referencing the lib folder of firebase-functions like this:
import { HttpsError } from 'firebase-functions/lib/providers/https'
...
throw new HttpsError('failed-precondition', 'An error')
The problem was gone after removing all of them and replacing with something like the following:
import { https } from 'firebase-functions'
...
throw new https.HttpsError('failed-precondition', 'An error')
The first approach worked until 3.14.1. Above that, it looks like we can't reference the lib folder in the from. Not ideal because I wanted to avoid the namespace when using these types, but at least it works.