Skip to content

Latest commit

 

History

History
51 lines (34 loc) · 1.55 KB

common-issues.md

File metadata and controls

51 lines (34 loc) · 1.55 KB

Common Issues and Solutions

ERR_REQUIRE_ESM Error with Firebase Emulators

Error Message

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

Solution

This error occurs specifically when Firebase Tools is installed via the curl script (firebase.tools). To resolve this:

  1. Remove existing Firebase Tools installation:
sudo rm -rf /usr/local/bin/firebase
  1. Choose one of these installation methods:
# Using npm (recommended)
npm install -g firebase-tools

# Using Homebrew (for macOS users)
brew install firebase-cli
  1. Verify the installation:
firebase --version

Why This Works

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