Skip to content
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

verifyDeveloperNodeModules() fails to discover "firebase-admin" #1262

Closed
ExtraBB opened this issue May 9, 2019 · 26 comments
Closed

verifyDeveloperNodeModules() fails to discover "firebase-admin" #1262

ExtraBB opened this issue May 9, 2019 · 26 comments

Comments

@ExtraBB
Copy link

ExtraBB commented May 9, 2019

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

@google-oss-bot
Copy link
Contributor

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

@thechenky
Copy link
Contributor

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

@thechenky thechenky transferred this issue from firebase/firebase-functions May 9, 2019
@ExtraBB
Copy link
Author

ExtraBB commented May 9, 2019

The emulator works on firebase-tools@6.8.0. This issue is likely related to #1243 and #1258

@yerzhant
Copy link

yerzhant commented May 9, 2019

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.

@yerzhant
Copy link

yerzhant commented May 9, 2019

[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)

@namcoder
Copy link

namcoder commented May 9, 2019

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

@diogolessa
Copy link

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

@ExtraBB
Copy link
Author

ExtraBB commented May 9, 2019

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

@diogolessa
Copy link

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

@caputchinefrobles
Copy link

caputchinefrobles commented May 9, 2019

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

EDIT: Downgrading "fix" confirmed.

@rafawashere
Copy link

I was having this issue I removed firebase-tools and reinstalled firebase-tools@6.8.0.

@chelopme
Copy link

chelopme commented May 9, 2019

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

@abeisgoat abeisgoat self-assigned this May 9, 2019
@abeisgoat
Copy link
Contributor

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.

@abeisgoat abeisgoat changed the title Can't start Functions emulator because firebase-admin is not available verifyNodeModules() fails to discover "firebase-admin" May 9, 2019
@abeisgoat abeisgoat changed the title verifyNodeModules() fails to discover "firebase-admin" verifyDeveloperNodeModules() fails to discover "firebase-admin" May 9, 2019
@abeisgoat
Copy link
Contributor

abeisgoat commented May 9, 2019

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

abeisgoat added a commit that referenced this issue May 9, 2019
@powolnymarcel
Copy link

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 firebase-tools@6.8.0

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

@LVeach
Copy link

LVeach commented May 9, 2019

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

@andria-dev
Copy link

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.

@abeisgoat
Copy link
Contributor

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.

@samtstern
Copy link
Contributor

Fixed by #1263

@samtstern
Copy link
Contributor

Version 6.9.2 has been released with this fix.

@andria-dev
Copy link

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

@LVeach
Copy link

LVeach commented May 11, 2019

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)

@naeemshaikh27
Copy link

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

  1. Cannot understand what targets to deploy error #1106
  2. Serve command does not change Functions Emulator port with --port flag #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

@shaunluttin
Copy link

shaunluttin commented May 28, 2019

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

@tranvietthanh1997
Copy link

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests