-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module 'firebase-admin/app' #1488
Comments
I found a few problems with this issue:
|
I have the same issue. For some reason, running |
Solved it by ignoring the import recommendation. Instead of
I am now using what existed before v10:
|
Code given above worked fine when executed through Node.js 12. Here's the output of the execution with an added
Also I can do the following on a Node.js REPL:
May be somebody can share a minimal and complete repro of the issue? Something that we can download and run to repro the problem? |
@hiranya911 I am currently using node Edit – I can confirm that downgrading to v12 did solve the issue. |
@shalbert94 Importing the top level module and then accessing internal things like you suggested works. So, either the docs need updating, or the library itself does. |
Works fine on Node 17 too:
This is most likely a problem specific to your environment/implementation. We will need a complete, minimal repro to know for sure. As fas as our library is concerned, we correctly declare the new module entry points in our firebase-admin-node/package.json Lines 106 to 111 in b26501b
All Node.js versions 12 and up, should support it. |
Assuming there are no other libraries, frameworks or custom module loaders in play, more likely explanation is your Node 17 setup was somehow loading an old version of firebase-admin (e.g. v9), that didn't have the new module exports. Changing to Node 12 pulled in the latest version of the library, and picked up the new entry points. Just a guess. |
I pushed a copy of my attempt to repro this issue to https://github.com/firebase/firebase-admin-node/tree/hkj-repro-1488/nodetest. Feel free to play with it and see if you can still repro the problem. |
I'm also getting this error when using the snippet provided: import { initializeApp, applicationDefault } from 'firebase-admin/app'; => Node v14.16.1 Confirming that using |
@Bandit can you share a complete repro with us? Something similar to the complete example I've shared above in my last comment. |
Folks who are seeing this error also please check their library version using one of the following methods: Using
|
Confirmed I'm using I'll see about building a repro when I get some time, but I'm assuming it's related to Vite (using Vite + Sveltekit). Perhaps fixed by this hot-off-the-press PR vitejs/vite#5593? Or maybe it's this bug vitejs/vite#4340? Bit beyond my pay grade |
We encountered the issue in Vite during alpha testing. See #1340 (also vitejs/vite#3953). It's a bug in their module resolver. We cannot do much about that on our end, but it sounds like the PR you've linked above is expected to fix it. Other platforms with known issues include Jest and ESLint (see #1481) |
Can confirm this is an issue when creating a graphql express application. Version is 10.0.0 import { initializeApp } from "firebase-admin/app"
import { getAuth } from "firebase-admin/lib/auth"
const firebaseApp = initializeApp()
const auth = getAuth(firebaseApp)
|
@DallasP9124 your import is wrong:
Should be corrected as:
|
Can confirm this issue occurs, as of today, on
Repro is just following the firebase setup docs, albeit with typescript imports. Update: Visual Studio code is able to see the firebase-admin/app module though. Its just that when I run a test case with jest with minimal setup of FCM admin, the error occurs. Looks like my issue is more related to: For now, the workaround is good. |
@hiranya911 that did fix it. I was using WebStorm and it resolved the import to the wrong location. |
I got fixed by updating fireabse-admin and node version as below. |
any updates on this issue ? I am not able to use modular imports on Node 16 |
I started getting this after installing the eslint-plugin-node module and enabling the plugin. The rule "node/no-missing-import": [
"error",
{
allowModules: ["firebase-admin"],
},
], |
@TheSecurityDev Yes, ESLint is another known case. See my earlier comment #1488 (comment) Open bug report in ESLint project: import-js/eslint-plugin-import#1868 |
Same problem here. The suggested method in the documentation did not work. However this solved it:
|
same problem node: v16.13.0
eslint {
'import/no-unresolved': [
'error',
{
ignore: ['^firebase-admin/.+'],
},
],
'node/no-missing-import': [
'error',
{
allowModules: ['firebase-admin'],
},
],
} working only importing import type { MulticastMessage } from 'firebase-admin/messaging' thx @pooyasa I also had to go back |
A co-worker had a similar issue, so just chiming in in case it helps someone. Basically, make sure you're running tooling that supports
firebase-admin-node/package.json Lines 108 to 111 in 7b15b27
In our case we were seeing discrepancies between developers' machines. Ensuring everyone was running Node 12.7 or greater resolved the issue. |
Had the same error in v9.5, works fine in v10 if I dont use |
I started to use firebase-admin@^10.0.1 and I had this error when running jest tests. It couldn't map "firebase-admin/app" to "firebase-admin/lib/app" as expected. So I have mapped this manually on jest.config.ts:
That worked for me. And just to note, my tsconfig.json is like this:
|
Similarly to @HelderSi, I had to do a moduleNameMapper config, but I'm using yarn v2 PnP, so my config looks like this:
|
For some reason npm pulled v9 for me, I manually edited my package.json (remember it's the one in the functions folder): |
backend package json
firebase library package.json |
Deleting node_modules, package-lock.json, and running |
For anyone else looking for things to try, learn from my mistake. When upgrading to firebase-admin@10, I accidentally made it a dev dependency, thus triggering this error. |
I did have the same issue with not finding the module 'firebase-admin/app'. Ended up accessing firebase products with suggestions from others at the top of this thread. Tried it again the default way from google docs , regardless of the error 'module not found' everything still works fine and able to use firebase product (firestore). You can IGNORE the error and run your code. I am node version 12 |
@Benjamin-Lee that fixed my issue. Thanks for share your error resolution. |
This issue is still not solved. Either I use node version 14.6.0 (npm v7.8.0) or version 18.1.0 (npm v8.8.0). |
I'm using node v18.12.0 with yarn and vscode. Runing |
Still experiencing this with firebase-admin@11.5.0 and node@18.15.0. Clearing the cache and re-installing did not help. I have tried the general import:
...but I can't get at the
Gives: Property 'getAuth' does not exist on type '(app?: App | undefined) => Auth'. |
@jasonburrows If you are using the namespaces you should use I ran a few tests and it seems like
In the meantime, I would also suggest using the new modular syntax:
|
package.json
requirements look like this –node_modules
has the corresponding module in the path~/node_modules/firebase-admin/lib/app
Node code reads as –
And when the app is run, the following stacktrace emerges.
The text was updated successfully, but these errors were encountered: