pulyaevskiy / firebase-functions-interop

Firebase Functions Interop Library for Dart.
BSD 3-Clause "New" or "Revised" License
191 stars 52 forks source link

serve is failing due to firebase-admin not being installed #62

Closed jimmyff closed 4 years ago

jimmyff commented 4 years ago

I've started getting an error message when I try to serve firebase 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've tried running npm install, I've also tried

npm install firebase-functions@latest --save
npm install firebase-admin@latest --save-exact

which was suggested on the official docs.

My package.json looks like this:

{
  "name": "functions",
  "description": "Cloud Functions for Firebase",
  "scripts": {
    "build": "pub run build_runner build --output=build",
    "watch": "pub run build_runner watch --output=build",
    "preserve": "npm run build",
    "serve": "firebase serve --only functions",
    "predeploy": "npm run build",
    "deploy": "firebase deploy --only functions",
    "preshell": "npm run build",
    "shell": "firebase experimental:functions:shell",
    "start": "npm run shell",
    "logs": "firebase functions:log"
  },
  "dependencies": {
    "@google-cloud/firestore": "0.18.0",
    "firebase-admin": "8.5.0",
    "firebase-functions": "^3.2.0"
  },
  "private": true,
  "main": "build/node/index.dart.js"
}

Versions are as follows:

pulyaevskiy commented 4 years ago

Wondering if updating @google-cloud/firestore to 2.0.0 would fix it?

I recently posted a new version of admin interop with some breaking changes in Firestore, but I haven't tested it with functions interop yes.

Check out changelog in admin interop and try to follow upgrade instructions. Let me know if the issue persists.

jimmyff commented 4 years ago

I upgraded firestore to 2.0.0 and it's getting further now but still failing, this is the output from serve:

> Executing task: npm run serve <

> functions@ preserve /Users/jimmyff/Development/onescene/functions
> npm run build

> functions@ build /Users/jimmyff/Development/onescene/functions
> pub run build_runner build --output=build

[INFO] Generating build script completed, took 352ms
[WARNING] Throwing away cached asset graph due to Dart SDK update.
[INFO] Cleaning up outputs from previous builds. completed, took 235ms
[INFO] Generating build script completed, took 69ms
[INFO] Creating build script snapshot... completed, took 11.1s
[INFO] Building new asset graph completed, took 1.7s
[INFO] Checking for unexpected pre-existing outputs. completed, took 16ms
[WARNING] build_modules:dart2js on lib/.dart2js.meta_module.raw:
Unable to read module information for package:web, make sure you have a dependency on it in your pubspec.
[WARNING] build_modules:dart2js on package:core/.dart2js.meta_module.raw:
Unable to read module information for package:web, make sure you have a dependency on it in your pubspec.
[INFO] build_node_compilers:entrypoint on node/index.dart:Running dart2js with --fast-startup --omit-implicit-checks --trust-primitives --packages=.package-5f36bc4a338b68119f6389f2a8c13550 -onode/index.dart.js node/index.dart
[INFO] build_node_compilers:entrypoint on node/index.dart:Dart2Js finished with:

Hint: 5 hint(s) suppressed in package:built_collection.
Hint: 1 hint(s) suppressed in package:built_value.
Hint: 2 hint(s) suppressed in package:firebase_admin_interop.
Hint: 3 hint(s) suppressed in package:source_span.
Compiled 10,229,457 characters Dart to 1,263,796 characters JavaScript in 7.01 seconds
Dart file node/index.dart compiled to JavaScript: node/index.dart.js

[INFO] Running build completed, took 10.6s
[INFO] Caching finalized dependency graph completed, took 177ms
[INFO] Reading manifest at build/.build.manifest completed, took 1ms
[INFO] Deleting previous outputs in `build` completed, took 645ms
[INFO] Creating merged output dir `build` completed, took 1.7s
[INFO] Writing asset manifest completed, took 7ms
[INFO] Succeeded after 13.1s with 725 outputs (3232 actions)

> functions@ serve /Users/jimmyff/Development/onescene/functions
> firebase serve --only functions

⚠  Your functions directory does not specify a Node version.
   - Learn more at https://firebase.google.com/docs/functions/manage-functions#set_runtime_options
✔  functions: Emulator started at http://localhost:5000
i  functions: Watching "/Users/jimmyff/Development/onescene/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)

in my package.json.lock file I see this:

...
    "firebase-admin": {
      "version": "8.5.0",
      "resolved": "https://registry.npmjs.org/firebase-admin/-/firebase-admin-8.5.0.tgz",
      "integrity": "sha512-rvgCj5Z1iFOT6K6uW37VRl4PKNpAcBFu/FIQ4Nl5bFnqbHSxf+QxzsqdsUtIxdqZU1yh2DTs2t+s5qORx/T9+g==",
      "requires": {
        "@firebase/database": "^0.5.1",
        "@google-cloud/firestore": "^2.0.0",
        "@google-cloud/storage": "^3.0.2",
        "@types/node": "^8.0.53",
        "dicer": "^0.3.0",
        "jsonwebtoken": "8.1.0",
        "node-forge": "0.7.4"
      },

I've also tried upgrading firestore to 2.3.0 but that gives the same result

jimmyff commented 4 years ago

Installing the latest version of firebase-tools fixed the issue. Sorry for the noise!