Search code examples
firebaseversion-controlangular2-nativescript

Plugin installation hangs after Nativescript 2.5.0 update


Did something significant change in version 2.5.0 of Nativescript?

Resulting from an error of my own doing. I accidentally uninstalled Nativescript through negligence and reinstalled it bringing my version from 2.4.1 (I believe) to 2.5.0. In the process I corrupted my working file.

Building a new one seems to work fine, but 2.5.0 has brought enough changes (to the app/package.json file perhaps) that I can't install the nativescript-plugin-firebase plugin. It just hangs like in the picture starting the installation but without the console.log information which was typical. See picture. without finishing the build no matter if it is installed through nativescript CLI or by setting it as a dependency in the root/package.json file. One thing I noticed is that tns build android would update the version to 2.5.0 as well. enter image description here

I've even tried setting the entire package.json file to be the versions that I used before and using tns update to set the nativescript version.

Is there a way I can reinstall Nativescript 2.4.1 as my principal install?

It seems that the plugin itself installs everything, but not the files in the scripts folder. They never prompt me to create the firebase.nativescript.json file either.

Here is the current package.json file after running tns create [MYAPP] --ng root/package.json

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.[MYAPP]"
  },
  "dependencies": {
    "@angular/common": "2.4.3",
    "@angular/compiler": "2.4.3",
    "@angular/core": "2.4.3",
    "@angular/forms": "2.4.3",
    "@angular/http": "2.4.3",
    "@angular/platform-browser": "2.4.3",
    "@angular/platform-browser-dynamic": "2.4.3",
    "@angular/router": "3.4.3",
    "nativescript-angular": "1.4.0",
    "nativescript-theme-core": "~1.0.2",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.0.1",
    "tns-core-modules": "^2.4.1"
  },
  "devDependencies": {
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-typescript": "~0.3.5",
    "typescript": "~2.1.0",
    "zone.js": "~0.7.2"
  }
}

and the app/package.json file

{
  "android": {
    "v8Flags": "--expose_gc"
  },
  "main": "main.js",
  "name": "tns-template-hello-world-ng",
  "version": "2.5.0"
}

Solution

  • The "firebase plugin hangs" issue seems to be tripped by the new NativeScript 2.5 CLI not handling the firebase plugin prompting the user for config options.

    You can find backstory on Github Issue for the plugin.

    The quick workaround is create a firebase.nativescript.json file at the root of your project, and enable the features you'd like. For example, I just use android and google_auth, so mine looks like this:

    {
        "using_ios": false,
        "using_android": true,
        "remote_config": false,
        "messaging": false,
        "crash_reporting": false,
        "storage": false,
        "facebook_auth": false,
        "google_auth": true
    }
    

    Once you've created that file with the desired config, you can happily run tns plugin add nativescript-plugin-firebase and it will complete since the CLI doesn't need to prompt for features any more.