Firebase-tools: When `serve --only hosting, functions` is executed in 6.9.0, there is no choice but to invoke only `functions`

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

[REQUIRED] Environment info


firebase-tools:

$ firebase --version
6.9.0


Platform:

macOS 10.14.1

[REQUIRED] Test case

minimal

firebase serve --only hosting,functions

verifiable

I was expecting booting local hosting and functions when I ran firebase serve --only hosting,functions.
But, booting only the local functions.

It worked as expected with [email protected].

complete

firebase.json

{
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "app"
      }
    ]
  },
  "functions": {
    "source": "functions"
  }
}

functions/package.json

{
  "name": "functions",
  "scripts": {
    "serve": "firebase serve --only functions",
    "shell": "firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {"node": "8"},
  "main": "lib/index.js",
  "dependencies": {
    "express": "^4.16.4",
    "firebase-admin": "~7.0.0",
    "firebase-functions": "^2.2.0"
  },
  "private": true
}

functions/lib/index.js

import * as functions from 'firebase-functions';
import * as express from 'express';

const application = express(); 

application.get('/', (req, res) => {
    res.redirect('/user');
});

export const app = functions.https.onRequest(application);

public/user/index.html

<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    HelloWorld                                                                                                                                                             
</body>
</html>

[REQUIRED] Steps to reproduce

  1. run firebase serve --only hosting,functions
  2. access to https://localhost:5000/

redirect not work.

[REQUIRED] Expected behavior

Local hosting works, and local functions also work.

[REQUIRED] Actual behavior

Invoke only the local functions.

emulator-suite bug

Most helpful comment

Also having the same problem, upgraded from 6.8.0 to 6.9.0 then the problem started.

As a workaround downgrade to the previous version:

npm i -g [email protected]

All 10 comments

Also having the same problem, upgraded from 6.8.0 to 6.9.0 then the problem started.

As a workaround downgrade to the previous version:

npm i -g [email protected]

Thanks for the report! This is definitely a regression in 6.9.0 and we'll get a fix out ASAP

@samtstern Thanks fixed.馃槏

@samtstern Thanks fixed.馃槏

How can I get this to work for me too? I see that 6.9.1 is not yet released.

I got the same problem but with 6.9.1 version fixed the issue. Now I have one problem with Error: Can't determine Firebase Database URL with firebase-admin. I recommend return to 6.8.0

@Ihernandezpi could you file a new issue about the database URL? That sounds like a bug!

@Ihernandezpi I think I found your issue:
https://github.com/firebase/firebase-tools/issues/1261

@Ihernandezpi I think I found your issue:

1261

I was writing the issue. But you wrote first. Thankyou for your attention @samtstern

Updated to 6.9.1 but I'm getting a new error message now. I erased all my files, cloned it again, run npm install on functions directory, but still getting the following message:

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.

Should I open a new issue?

Complete stack:

E:\dev\cbpq-firebase>firebase serve --only functions,hosting
+  functions: Using node@10 from host.
+  functions: Emulator started at http://localhost:5001
i  functions: Watching "E:\dev\cbpq-firebase\functions" for Cloud Functions...
i  hosting: Serving hosting files from: public
+  hosting: Local server: http://localhost:5000
!  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)

@epomatti Yes please open a new issue.

Was this page helpful?
0 / 5 - 0 ratings