firebase / firebase-functions

Firebase SDK for Cloud Functions
https://firebase.google.com/docs/functions/
MIT License
1.01k stars 201 forks source link

Emulators: Cannot find module 'firebase-functions/lib/providers/https' #1481

Closed nicolasheady closed 8 months ago

nicolasheady commented 8 months ago

[REQUIRED] Version info

node: 18.15.0

firebase-functions: 4.5.0

firebase-tools: 12.8.0

firebase-admin: 11.10.0

[REQUIRED] Test case

const {onRequest} = require("firebase-functions/v2/https");
const logger = require("firebase-functions/logger");
const express = require("express");
const cors = require("cors");

const app = express();
app.use(cors());

app.get("/helloWorld", (req, res) => {
  res.send("Hello!");
});

exports.app = onRequest(app);

[REQUIRED] Steps to reproduce

  1. Create functions (above).
  2. Run emulators for Functions (firebase emulators:start --only functions)

[REQUIRED] Expected behavior

Expect emulator to start without issue.

[REQUIRED] Actual behavior

emulators: Starting emulators: functions
functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: auth, firestore, database, hosting, pubsub
functions: Using node@18 from host.
ui: Emulator UI logging to ui-debug.log
functions: Watching "/Users/.../Firebase/project/functions" for Cloud Functions...
functions: Cannot find module '/Users/.../project/functions/node_modules/firebase-functions/lib/providers/https'
Require stack:
- /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js
⚠  Your function was killed because it raised an unhandled error.

Were you able to successfully deploy your functions?

Getting this error on deploy: package.json in functions directory has an engines field which is unsupported. Valid choices are: {"node": "8"}, {"node": "10"}, and {"node":"12"}.

google-oss-bot commented 8 months ago

I found a few problems with this issue:

nicolasheady commented 8 months ago

Turns out I had two versions of the Firebase CLI installed on my Mac. A very old version installed in "/usr/local/bin/firebase", and the newest version in "/Users/username/.nvm/versions/node/v18.15.0/bin/firebase" When using the "Firebase" command to deploy or run emulators, it was using the old version of the CLI, pre Gen 2. I deleted that one and now 'Firebase' commands are using the updated CLI.

nicolasheady commented 8 months ago

Closing for above reason.