angularfire: ng add @angular/fire -> Package install failed

Running ng add @angular/fire on a fresh install of Angular results into Package install failed

Version info

Angular: 13.1.2 Node: 16.13.1 npm: 8.1.2 Firebase: 10.0.1 AngularFire: 7.2.0 OS: macOS Monterey (12.0.1)

How to reproduce these conditions

ng new <project>
ng add @angular/fire (no matter which option is chosen)

Result

ℹ Using package manager: npm
✔ Found compatible package version: @angular/fire@7.2.0.
✔ Package information loaded.

The package @angular/fire@7.2.0 will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.
UPDATE package.json (1171 bytes)
✔ Packages installed successfully.
? What features would you like to setup? ng deploy -- hosting
✖ Package install failed.
/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/util/hostReportError.js:4
    setTimeout(function () { throw err; }, 0);
                             ^

TypeError: Cannot read properties of undefined (reading 'message')
    at Object.error (/Users/<user>/Projects/<project>/node_modules/@angular/cli/models/schematic-command.js:432:47)
    at SafeSubscriber.__tryOrUnsub (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:205:16)
    at SafeSubscriber.error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:156:26)
    at Subscriber._error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:92:26)
    at Subscriber.error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:72:18)
    at TapSubscriber._error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/operators/tap.js:75:26)
    at TapSubscriber.Subscriber.error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:72:18)
    at MergeMapSubscriber.SimpleOuterSubscriber.notifyError (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/innerSubscribe.js:72:26)
    at SimpleInnerSubscriber._error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/innerSubscribe.js:30:21)
    at SimpleInnerSubscriber.Subscriber.error (/Users/<user>/Projects/<project>/node_modules/@angular-devkit/schematics/node_modules/rxjs/internal/Subscriber.js:72:18)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 25
  • Comments: 20

Most upvoted comments

I found that if you run npm i -D firebase-tools manually, this will fix the problem. If this doesn’t work, try: npm i -D firebase-tools@9

Had the same error message. Just ran the install script with sudo and got past it: sudo ng add @angular/fire

ng version output:

Angular CLI: 13.1.3
Node: 16.13.2
Package Manager: npm 8.3.1
OS: linux x64

Angular: 13.1.1
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1301.2
@angular-devkit/build-angular   13.1.2
@angular-devkit/core            13.1.2
@angular-devkit/schematics      13.1.3
@angular/cdk                    13.1.2
@angular/cli                    13.1.3
@angular/fire                   7.2.0
@angular/material               13.1.2
@schematics/angular             13.1.3
rxjs                            7.4.0
typescript                      4.5.4

Installing firebase-tools fixed the issue

firebase login npm i -D firebase-tools ng add @angular/fire@latest

Try the following, it did work for me

npm install --save-dev @angular/cli@latest && \
sudo npm install --save-dev @angular/cli@latest -g && \
npm i -D firebase-tools && \
ng add @angular/fire@latest

I believe I found a solution: It was mentioned in issue #3121 that a downgrade to firebase-tools@9.9.0 fixes this. And low and behold, it did. So I did not get the error in THIS issue, but that from 3121. Apologies.

It still doesn’t work soo frustrating !

ng add @angular/fire@latest

ℹ Using package manager: npm ✔ Package information loaded.

The package @angular/fire@latest will be installed and executed. Would you like to proceed? Yes ✖ Packages installation failed, see above.

npm i -D firebase-tools

Thanks