angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Running ng add @angular/fire does not add firebase to dependencies

Open lisp719 opened this issue 6 years ago • 6 comments

Version info

Angular: 9.1.9

Firebase:

AngularFire: 6.0.0

Other (e.g. Ionic/Cordova, Node, browser, operating system):

How to reproduce these conditions

npx @angular/cli new myapp
cd myapp
npx ng add @angular/fire

The cause is probably here. deps.version is incorrect.

https://github.com/angular/angularfire/blob/9e65e9dea74eaa3004c6c43bfd7d96df5ece6e54/src/schematics/ng-add-common.ts#L98-L104

Failing test unit, Plunkr, or JSFiddle demonstrating the problem

Steps to set up and reproduce

Sample data and security rules

Debug output

** Errors in the JavaScript console **

** Output from firebase.database().enableLogging(true); **

** Screenshots **

Expected behavior

Actual behavior

lisp719 avatar May 28 '20 16:05 lisp719

@lisp719 what do you suggest? please give me some instruction, I will make an PR for you

hiepxanh avatar Jun 02 '20 03:06 hiepxanh

Running ng add @angular/fire won't install firebase, so you'll have to use the npm command to install it.

And that's not mentioned in the documentation.

It's probably just that the typo doesn't install firebase, and the correct behavior is that it also installs firebase.

I think I can fix it, so I'll give it a try.

lisp719 avatar Jun 02 '20 11:06 lisp719

Fixed in 6.0.1.

jamesdaniels avatar Jun 26 '20 22:06 jamesdaniels

I'm still getting this problem on Windows 10 Pro Git Bash:

$ node -v v14.17.1

$ ng new delete-me output as expected

$ cd delete-me

$ ng add @angular/fire

  • Determining package manager... ℹ Using package manager: npm
  • Searching for compatible package version... ✔ Found compatible package version: @angular/[email protected].
  • Loading package information from registry... ✔ Package information loaded. Command aborted.

$ echo $? 1 # exit code

danday74 avatar Jul 04 '21 10:07 danday74

Hi,

I have the same probleme with Windows 10 Pro and Git Bash. I use PowerShell and all is ok.

Marc

marcteyssier avatar Jul 06 '21 20:07 marcteyssier

@marcteyssier

Here's the solution for Windows 10 and Git Bash:

winpty node_modules/.bin/ng.cmd add @angular/fire

and to deploy:

winpty node_modules/.bin/ng.cmd deploy

You will probably first need to login to firebase with:

npx firebase login --interactive (this will only work if you have npm installed firebase in your project already - I believe the failing command ... ng add @angular/fire ... will install firebase before failing) - so the final solution would look like this:

FINAL SOLUTION

ng add @angular/fire (fails but installs firebase locally) npx firebase login --interactive (logs into firebase) winpty node_modules/.bin/ng.cmd add @angular/fire

and to deploy:

winpty node_modules/.bin/ng.cmd deploy

danday74 avatar Jul 07 '21 00:07 danday74