node:internal/modules/cjs/loader:986
throw new ERR_REQUIRE_ESM(filename, true);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/XXXXX/.cache/firebase/emulators/ui-v1.11.8/server/server.mjs not supported.
Instead change the require of /Users/XXXXX/.cache/firebase/emulators/ui-v1.11.8/server/server.mjs to a dynamic import() which is available in all CommonJS modules.
at Function.runMain (pkg/prelude/bootstrap.js:1979:12) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v18.5.0
This error occurs specifically when Firebase Tools is installed via the curl script (firebase.tools). To resolve this:
- Remove existing Firebase Tools installation:
sudo rm -rf /usr/local/bin/firebase
- Choose one of these installation methods:
# Using npm (recommended)
npm install -g firebase-tools
# Using Homebrew (for macOS users)
brew install firebase-cli
- Verify the installation:
firebase --version
When installed via firebase.tools (curl script), the CLI comes bundled with Node.js to allow running without Node.js being pre-installed. A recent release of the emulator UI added a require() of an ES module, which is incompatible with the bundled Node.js configuration. Installing through npm or Homebrew uses your system's Node.js installation instead of the bundled version, avoiding the ESM compatibility issue.
Source: Firebase Tools Issue #6931