Firebase-tools: verifyDeveloperNodeModules() does not properly detected uninstalled modules

Created on 21 May 2019  路  7Comments  路  Source: firebase/firebase-tools

[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

emulator-suite functions

Most helpful comment

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

All 7 comments

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

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?

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.

Thanks for taking this on @abeisgoat

@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!

No repro needed, thanks, fix coming soon.

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

Was this page helpful?
0 / 5 - 0 ratings