Firebase-tools: verifyDeveloperNodeModules() fails to discover "firebase-admin"

Created on 9 May 2019  ·  26Comments  ·  Source: firebase/firebase-tools

Related issues

1243 and #1258

[REQUIRED] Version info

node: 8.16.0

firebase-functions: 2.3.0

firebase-tools: 6.9.1 (NOTE: Works on 6.8.0)

firebase-admin: 7.3.0

I am running this on Windows 10.

[REQUIRED] Test case


A freshly generated firebase project using firebase init with functions.

[REQUIRED] Steps to reproduce

  1. Run npm run start (or firebase functions:shell)

[REQUIRED] Expected behavior


The emulator starts correctly

[REQUIRED] Actual behavior

The following logs are shown:

!  The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i  functions: Your functions could not be parsed due to an issue with your node_modules (see above)

Were you able to successfully deploy your functions?


Yes, deploying works fine. The deployed function (hello world) as well

emulator-suite bug

Most helpful comment

This is a bug in firebase-tools versions 6.9.0 and 6.9.1. The solution is to downgrade to 6.8.0 for now:

npm install -g [email protected]

ref: https://stackoverflow.com/a/56065094/4319131

All 26 comments

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

Moving over to firebase-tools as that's where the emulation is implemented.

The emulator works on [email protected]. This issue is likely related to #1243 and #1258

Experiencing the same issue:

✔  functions: Using node@8 from host.
✔  functions: Emulator started at http://localhost:5001
i  functions: Watching "/home/yerzhan/projects/askimam/functions" for Cloud Functions...
⚠  The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i  functions: Your functions could not be parsed due to an issue with your node_modules (see above)
firebase -V
6.9.1
  "dependencies": {
    "firebase-admin": "^7.3.0",
    "firebase-functions": "^2.3.0"
  },

Though the firebase-admin package does exist in node_modules.

[2019-05-09T09:19:26.091Z] ----------------------------------------------------------------------
[2019-05-09T09:19:26.093Z] Command:       /home/yerzhan/node-v8.12.0-linux-x64/bin/node /home/yerzhan/node-v8.12.0-linux-x64/bin/firebase emulators:start --debug
[2019-05-09T09:19:26.093Z] CLI Version:   6.9.1
[2019-05-09T09:19:26.093Z] Platform:      linux
[2019-05-09T09:19:26.093Z] Node Version:  v8.12.0
[2019-05-09T09:19:26.094Z] Time:          Thu May 09 2019 15:19:26 GMT+0600 (+06)
[2019-05-09T09:19:26.094Z] ----------------------------------------------------------------------

[2019-05-09T09:19:26.099Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2019-05-09T09:19:26.099Z] > authorizing via signed-in user
[2019-05-09T09:19:26.100Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[2019-05-09T09:19:26.100Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[2019-05-09T09:19:26.891Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=utf-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 09 May 2019 09:19:26 GMT, server=scaffolding on HTTPServer2, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, transfer-encoding=chunked
[2019-05-09T09:19:26.901Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/azan-kz-ask-imam  

[2019-05-09T09:19:28.625Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 09 May 2019 09:19:28 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, server-timing=gfet4t7; dur=923, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, transfer-encoding=chunked
i  Starting emulators: ["functions"]
✔  functions: Using node@8 from host.
[2019-05-09T09:19:28.637Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/674391970261:getServerAppConfig  

[2019-05-09T09:19:29.356Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Thu, 09 May 2019 09:19:29 GMT, server=ESF, cache-control=private, x-xss-protection=0, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="46,44,43,39", accept-ranges=none, transfer-encoding=chunked
✔  functions: Emulator started at http://localhost:5001
i  functions: Watching "/home/yerzhan/projects/askimam/functions" for Cloud Functions...
[2019-05-09T09:19:29.813Z] Functions runtime initialized.
[2019-05-09T09:19:29.813Z] Disabled runtime features: undefined
⚠  The Cloud Functions emulator requires the module "firebase-admin" to be installed. This package is in your package.json, but it's not available. You probably need to run "npm install" in your functions directory.
i  functions: Your functions could not be parsed due to an issue with your node_modules (see above)

I have the same and found solution:
You can use the alias command like this: "yarn serve" or "npm serve"
It will call from the packages.json , in "scripts" block

Same issue here! Tried to found a workaround during 3 hours, but without success.
Today I just thought about adding firebase-admin to global npm, but not sure if it should work.
Will try out your suggestion @namcoder

@diogolessa Downgrading to firebase-tools 6.8.0 also fixes the problem, is that not an option for you?

Sure, can be... Looks like a better approach. Though, would be nice to have all the newest versions working normally for beginners like me. Thanks @ExtraBB

Same here... It happens on linux as well.

EDIT: Downgrading "fix" confirmed.

I was having this issue I removed firebase-tools and reinstalled [email protected].

Same issue.. downgrading is the only way to make it work

Only setting that currently works
firebase-functions: 2.3.0
firebase-tools: 6.8.0
firebase-admin: 7.3.0

Hey folks, sorry about the trouble this issue is causing. For now we recommend downgrading to 6.8.0 while we work on a patch.

This issue is caused by the use of the native require.resolve in verifyDeveloperNodeModules() where slowRequireResolve should be used. The other use of native require.resolve will also suffer from the same issue.

This was not caught in our tests because require.resolve resolved to the dev dependencies of firebase-tools when running in tests, so it made it appear that there was no behavior difference between require.resolve and slowRequireResolve

This is a bug in firebase-tools versions 6.9.0 and 6.9.1. The solution is to downgrade to 6.8.0 for now:

npm install -g [email protected]

ref: https://stackoverflow.com/a/56065094/4319131

Thank you for the updates. Downgrading to 6.8.0 worked for us

This is not currently documented in the firebase docs for running functions locally and definitely needs to be if a fix isn't already ready.

Alright folks, we've just merged in a fix for this which will go out in 6.9.2 today. We may wait on a fix for #1265 before releasing, but if that doesn't make it, this will go out as is. Once it's out, I'll close this bug, but please re-open if the issue is still happening for you.

Fixed by #1263

Version 6.9.2 has been released with this fix.

Getting the following error, wondering if it's related to this new release:

AssertionError [ERR_ASSERTION]: missing path
    at Module.require (module.js:595:3)
    at require (internal/module.js:11:18)
    at InitializeFirebaseAdminStubs

upgraded from 6.8.0 to 6.9.2 and am now seeing:

functions: Using node@8 from host.

! The Cloud Functions emulator requires the module "firebase-functions-test" to be installed as a development dependency. To fix this, run "npm install --save-dev firebase-functions-test" in your functions directory.
i functions: Your functions could not be parsed due to an issue with your node_modules (see above)

I am getting a lot of errors after upgrading to 6.9.2.

  1. https://github.com/firebase/firebase-tools/issues/1106
  2. https://github.com/firebase/firebase-tools/issues/1265
    and few more bugs after trying to tackle down the existing ones.
    this upgrade is way more broken. had to downgrade to 6.8.0

Version 6.9.2 has been released with this fix.

The fix didn't stick. We are seeing this error in "firebase-tools": "^6.10.0".

The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin@latest" in your functions directory.

We have removed the ^ from our package.json dependency for now to prevent the automatic upgrade on install.

"firebase-tools": "^6.8.0", // before
"firebase-tools": "6.8.0", // after

@diogolessa Downgrading to firebase-tools 6.8.0 also fixes the problem, is that not an option for you?

Thank you, it's worked for me

Was this page helpful?
0 / 5 - 0 ratings