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() does not properly detected uninstalled modules #1320

Closed
MatteoGioioso opened this issue May 21, 2019 · 7 comments

Comments

@MatteoGioioso
Copy link

MatteoGioioso commented May 21, 2019

[REQUIRED] Environment info

firebase-tools: 6.10.0
Ubuntu 18.04.2 LTS

[REQUIRED] Steps to reproduce

I just upgrade from firebase-tools 6.8.0 to 6.10.0
and when try to run firebase serve --only functions,hosting
I get this error

Error: Cannot find module 'package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
    at Function.Module._load (internal/modules/cjs/loader.js:591:27)
    at Module.require (internal/modules/cjs/loader.js:723:19)
    at require (internal/modules/cjs/helpers.js:14:16)
    at verifyDeveloperNodeModules (/usr/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:120:32)
    at /usr/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:435:26
    at Generator.next (<anonymous>)
    at /usr/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:7:71
    at new Promise (<anonymous>)
    at __awaiter (/usr/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:3:12)

[REQUIRED] Expected behavior

It should run normally
This is not happening with version 6.8.0

[REQUIRED] Actual behavior

It throws an error

For now I just downgraded back to 6.8.0

@google-oss-bot
Copy link
Contributor

This issue does not seem to follow the issue template. Make sure you provide all the required information.

@MatteoGioioso MatteoGioioso changed the title Error: Cannot find module 'package.json' Error: Cannot find module 'package.json' with version 6.10.0 May 21, 2019
@bkendall
Copy link
Contributor

Can you provide a bit more about your setup? We need enough information so we can fully replicate your issue. Do you have customization in firebase.json? Where do your functions and hosting code live relative to where you're running the firebase command?

@bkendall bkendall added emulator-suite Needs: Author Feedback Issues awaiting author feedback labels May 21, 2019
@abeisgoat abeisgoat changed the title Error: Cannot find module 'package.json' with version 6.10.0 verifyDeveloperNodeModules() does not properly detected uninstalled modules May 21, 2019
@abeisgoat
Copy link
Contributor

abeisgoat commented May 21, 2019

This regression was caused in the change from require.resolve to slowRequireResolve in the functionsEmulatorRuntime. Specifically, on line #198 there is no situation where slowRequireResolve will throw an error whereas require.resolve will throw when a module isn't resolvable.

Without the throw, we never detect the module as uninstalled, so we attempt to locate package.json for that module (which doesn't exist). This causes your error, you can probably route around this by running npm install firebase-functions-test --save-dev in your functions directory (in theory this error could come from missing firebase-admin, firebase-functions or firebase-functions-test, but in all likelihood you probably already have the first two.

To fix this, we should make slowRequireResolve throw when it is incapable of resolution.

I will get a fix in for the next release.

@bkendall
Copy link
Contributor

Thanks for taking this on @abeisgoat

@MatteoGioioso
Copy link
Author

@bkendall Ugh, sorry for the late replay. If still needed I can get small repo and try to reproduce the error. Let me know thanks!

@abeisgoat
Copy link
Contributor

No repro needed, thanks, fix coming soon.

@abeisgoat
Copy link
Contributor

Fix has been merged into next branch so it'll go out with the [email protected] release

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

5 participants