angularfire: ng add error - catch clause variable is not an Error instance

Version info

Angular:. 14.2.0

How to reproduce these conditions

  1. ng new App
  2. ng add @angular/fire

Debug output

** Errors in the JavaScript console **

An unhandled exception occurred: catch clause variable is not an Error instance See “/private/tmp/ng-qfEJEW/angular-errors.log” for further details.

** Output from /private/tmp/ng-qfEJEW/angular-errors.log **

[error] AssertionError [ERR_ASSERTION]: catch clause variable is not an Error instance at assertIsError (/xxx/node_modules/@angular/cli/src/utilities/error.js:19:26) at AddCommandModule.runSchematic (/xxx/node_modules/@angular/cli/src/command-builder/schematics-command-module.js:304:43) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async AddCommandModule.executeSchematic (/xxx/node_modules/@angular/cli/src/commands/add/cli.js:283:20) at async AddCommandModule.handler (/xxx/node_modules/@angular/cli/src/command-builder/command-module.js:111:24)

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 9
  • Comments: 18 (2 by maintainers)

Most upvoted comments

I had the same error and I fixed it using the sudo command followed by ng add @angular/fire I am using pnpm as package manager. It works for me on Mac Ventura 13.2.1


First time

ng add @angular/fire ℹ Using package manager: pnpm ✔ Found compatible package version: @angular/fire@7.5.0. ✔ Package information loaded.

The package @angular/fire@7.5.0 will be installed and executed. Would you like to proceed? Yes ✔ Packages successfully installed. UPDATE package.json (1158 bytes) ✔ Packages installed successfully. ? What features would you like to setup? Firestore ✖ Package install failed. An unhandled exception occurred: catch clause variable is not an Error instance See “/private/var/folders/rh/rbr0nmcn6g9f0qwjl930tmpc0000gn/T/ng-HXREZu/angular-errors.log” for further details.


Second time

sudo ng add @angular/fire Skipping installation: Package already installed UPDATE package.json (1158 bytes) ✔ Packages installed successfully. ? What features would you like to setup? Firestore Using firebase-tools version 11.24.1 ? Which Firebase account would you like to use? youremailaccount@gmail.com ✔ Preparing the list of your Firebase projects ? Please select a project: my-project ✔ Preparing the list of your Firebase WEB apps ? Please select an app: [CREATE NEW APP] ? What would you like to call your app? my-project ✔ Creating your Web app ✔ Downloading configuration data of your Firebase WEB app UPDATE .gitignore (602 bytes) UPDATE src/app/app.module.ts (984 bytes) UPDATE src/environments/environment.ts (959 bytes) UPDATE src/environments/environment.prod.ts (352 bytes)

you can also npm install -g firebase-tools firebase login

You can also work around this issue by installing firebase-tools as a dev dependency before running the schematic.

e.g.

yarn add -D firebase-tools

[Solved] (for my case).

Hey, yeah, so I was having this same issue too on my Intel-chip Macbook Pro running Ventura.

I noticed the command was dying when installing the firebase-tools (which I missed at first since I wasn’t watching the install, after all it should just work, right? 😉. Chances are that you already have firebase-tools installed as part of the setup process if you’ve been working in Firebase.

At first I tried to uninstall it using npm but with no luck, so I decided to remove it manually (TRUST ME, not too hard)

So I checked where the firebase tools executable was installed (run ‘which firebase’ to find out where it is) and moved it to a different folder, you could also delete it (which I did later).

I, then, ran (sudo - for me) ng add @angular/fire again which reinstalled the firebase tools again, and it all worked this time.

Give me a like if this helps anyone.