firebase-tools-ui: Firebase Emulator Suite UI unable to start

Note: Before filing bugs in this repo, please ensure that this is a bug for the Emulator Suite UI. Emulator Suite and/or Firebase CLI bugs should be filed under the firebase-tools repo here: https://github.com/firebase/firebase-tools/issues/new/choose

Describe the bug A clear and concise description of what the bug is.

This issue on stackflow covers the error I am seeing when acccessing the Emulator UI https://stackoverflow.com/questions/75840698/i-cannot-run-firebase-emulators-on-fresh-install-getting-syntaxerror-unexpec

To Reproduce Steps to reproduce the behavior:

I am using a fresh install of Firebase tools on Mac.

firebase --version

11.25.1

MacOS

13.2.1 (22D68)

firebase emulators:start results in a UI error logged

/Users/r/.cache/firebase/emulators/ui-v1.11.4/server/server.js:569
        re"use strict";
          ^^^^^^^^^^^^

SyntaxError: Unexpected string
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.8.1

Expected behavior Should be able to start the Firebase Emulator suite UI

Screenshots N/A

Desktop (please complete the following information):

  • OS: MacOS 13.2.1
  • Browser: ChromeOS
  • Version: 111.0.5563.110

Smartphone (please complete the following information):

N/A

Additional context New Flutter project added Authentication and Cloud Firestore emulator components. npm: 9.5.1 node: 19.8.1 openjdk version “11.0.18” 2023-01-17 OpenJDK Runtime Environment Homebrew (build 11.0.18+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 13
  • Comments: 41 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Copy & Paste Solution:

brew install node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

I downgraded my node to LTS v16.19.1 and flushed the cache. That did the trick - I can now start the emulator on my device.

brew install node@16

flush the cache

rm -rf ~/.cache/firebase

Only thing that worked for me was to go to ~/.cache/firebase/emulators/ui-v1.11.5 and manually unzip ui-v1.11.5.zip there.

For those who is struggling with this issue, please read my comment here: https://github.com/firebase/firebase-tools/issues/5614#issuecomment-1508515106 to understand what’s going on.

How to fix: Essentially you need to make sure you installing your emulators using node 18.15.0 or lower. If you have your emulators installed using higher version of node: remove it from cache folder (usually ~/.cache/firebase).

Unfortunately it’s not very easy to install a specific node version in your docker container. In the comment I shared my dockerfile to provide an idea of how to install it with nvm.

CC @DevDaveFrame @Durisvk

Hi @rosera, I believe Java version is not important, replying to:

From the initial issue, there are two issues at play.

  1. Not using Node.js LTS version.
  2. Not using the Java 11 version.

PS: One more comment about LTS version as a solution: No, it won’t work and if this does work it’s sheer luck, because what really happens is:

  • You are using cached emulators downloaded by good version of node (v18.15.x/v19.7.x or lower) .
  • The repository that you’ve downloaded your LTS node from is still giving you v18.15.0 and not v18.16.0 which is the latest one as of today and running on which firebase-tools struggle to unzip downloaded PubSub & UI emulators.

CC @christhompsongoogle

Downgrading to Node 18 and clearing the cache as decribed above (copied here for signal boost) seems to resolve the issue. Node 19 is an experimental release. I’m still not clear why the cache clear is required though. There’s a new release of the UI coming out this week that may resolve it.

nvm install --lts
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

I get the exact same error on my Mac. Even after following the instructions by @christhompsongoogle. Node 19 or 18, and deleting cache, produces the same error.

Running NodeJS 18 and firebase-tools 11.27.0 here. Tried manually clearing the cache, unfortunately that didn’t help. Unzipping the cache myself did work though, for some reason.

Looking at the difference between the 2 server.js files, there’s, what looks to me, like some transpilation/bundling that’s happening differently.

Same - issue occurs for me. Using firebase-tools v12.5.3.

Downgrading to Node v18.15 fixed it.

Thank you all for the reports - this is caused by a break in our unzipper library dependency. We have a fix pending from Durisvk and are trying to get that in ASAP to resolve this issue.

Workaround:

  • Downgrade your node.js version to 18.5 or earlier
  • Remove your .cache/firebase to ensure the emulators are freshly downloaded (and unzipped).

In my case I had a fresh install on a MacOS and Linux hosts (relevant tech stack in the original post).

I didnt need to reinstall the tooling e.g. npm i -g firebase-tools. Downgrading the node version and removing the local cache did the trick for my situation.

Using the following Dockerfile I am able to replicate the original error message:

FROM debian:stable-slim

# Install updates
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y curl gcc g++ make default-jre
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN apt-get install -y nodejs

RUN npm install -g firebase-tools
RUN useradd -ms /bin/bash firebase-dev

USER firebase-dev
WORKDIR /home/firebase-dev

Build the image

docker build -t firebase-dev .

Run the container interactively with access to the host network

docker run -it --net=host firebase-dev /bin/bash

Then

  • firebase login
  • firebase init
  • Add Authentication Emulator and use default port values
  • firebase emulators:start

At this point the following error message is shown:

firebase-dev@penguin:~$ firebase emulators:start
i  emulators: Starting emulators: auth
i  ui: downloading ui-v1.11.4.zip...
Progress: ========================================================================================================================================================================================================================> (100% of 4MB)
i  ui: Emulator UI logging to ui-debug.log
⚠  ui: Fatal error occurred: 
   Emulator UI has exited with code: 1, 
   stopping all running emulators
i  ui: Stopping Emulator UI
⚠  ui: Error stopping Emulator UI
i  auth: Stopping Authentication Emulator
i  hub: Stopping emulator hub
i  logging: Stopping Logging Emulator
firebase-dev@penguin:~$ cat ui-debug.log
/home/firebase-dev/.cache/firebase/emulators/ui-v1.11.4/server/server.js:569
        re"use strict";
          ^^^^^^^^^^^^

SyntaxError: Unexpected string
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1195:20)
    at Module._compile (node:internal/modules/cjs/loader:1239:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.8.1

Using NVM on a mac.

Works for me with node 20.11.1 but only through the terminal and running firebase emulators:start. I get the same problem when running npm run ..., or using the Webstorm Run feature.

can confirm that pub/sub breaks the emulator on Latest LTS Version: 18.16.0

I tried downgrading node version, Java version, etc. Not much seemed to work. Unzipped ui-v1.11.5.zip manually in ~/.cache/firebase, and it’s working now. My env is now OpenJDK 11 and Node 18.15.0 .

Got the same problem with node 18.16 (ui-emulator v1.11.5). Downgrading node to 18.15 and removing ~/.cache/firebase solved the issue.

Copy & Paste Solution:

brew install node@16
export PATH="/opt/homebrew/opt/node@16/bin:$PATH"
rm -rf ~/.cache/firebase
npm install -g firebase-tools
firebase emulators:start

Worked for me. Very annoying problem firebase team 😦

@CTxD you can also go for version @18 and works fine

I had an issue using the solutions above, due to multiple node versions installed with Homebrew.

I solved it with these steps:

  1. brew install node@18
  2. brew unlink node
  3. brew link node@18
  4. rm -rf ~/.cache/firebase
  5. firebase emulators:start --import persisted_data --export-on-exit