Search code examples
angularfirebaseangularfire2

ng add @angular/fire error Cannot run login in non-interactive mode


When I run:

ng add @angular/fire

I get this error:

$ ng add @angular/fire
Skipping installation: Package already installed
UPDATE package.json (1542 bytes)
- Installing packages (npm)...
✔ Packages installed successfully.
Cannot run login in non-interactive mode. See login:ci to generate a token for use in non-interactive environments.

I am running this on Windows 10 Pro Git Bash.

This failure is causing other errors, e.g. ng deploy fails because ng add @angular/fire fails to update angular.json with a deploy target. Any ideas what the problem is? many thanks

Running on Node v14.17.1 and @angular/cli v11.2.14


Solution

  • OK this is a Windows issue.

    Instead of:

    ng add @angular/fire
    

    Run:

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

    If that fails then try:

    npx firebase login --interactive // firebase should have been installed locally when the previous command failed
    winpty node_modules/.bin/ng.cmd add @angular/fire
    

    Also, instead of:

    ng deploy
    

    Run:

    winpty node_modules/.bin/ng.cmd deploy
    

    Finally, you probably want to update your package.json deploy script to look like this:

    "scripts": {
      ...
      "deploy": "ng deploy",
      "deploy:win": "winpty node_modules/.bin/ng.cmd deploy"
    },
    

    Decent OS users can deploy with npm run deploy and Windows users can deploy with npm run deploy:win