Build failed in Ionic Pro : Cannot find module '@firebase/app-types/private'


#1

Hi all,

I have this error when building my project with Ionic Pro :
Cannot find module '@firebase/app-types/private’
The strange thing is that it builds fine locally and this error seems to be related to the last firebase module version 4.8.1 when locally I am using version 4.5.0.

Doesn’t the build process in Ionic Pro take into account the modules versions defined in package.json ?
Can anyone help me on that ?

Here’s the build logs :

Running with gitlab-ci-multi-runner 9.1.0 
(0118d89) on ip-10-2-90-23 (c9648220) 
Using Shell executor... 
Running on ip-10-2-90-23... 
Cloning repository... 
Cloning into '/home/gitlab-runner/builds/c9648220/0/project-1'... 
Checking out 0276eecb as master... 
Skipping Git submodules setup 
$ run "fetch-updates" Running Stage fetch-updates for Job: 5213190 
Checking for build process updates... $ run "build-app" 
Running Stage build-app for Job: 5213190 
Parsing ionic.config.json for project settings Project Settings: 	
Name: screenAddict 	
App ID: 8ef117f3 	
Type: ionic-angular
$ npm install --quiet --no-optional 
npm WARN deprecated cordova-plugin-console@1.0.5: This plugin has been deprecated since it is now included in the latest versions of cordova-ios 
npm WARN deprecated babili@0.1.2: babili has been renamed to babel-minify. Please update to babel-minify 
npm WARN deprecated babel-preset-babili@0.1.4: babili has been renamed to babel-minify. Please update to babel-preset-minify 
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys 
> grpc@1.8.0 install /usr/src/app/node_modules/grpc 
> node-pre-gyp install --fallback-to-build --library=static_library 
[grpc] Success: "/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node" is installed via remote 
> node-sass@4.5.3 install /usr/src/app/node_modules/node-sass 
> node scripts/install.js 
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-57_binding.node 
Download complete 
Binary saved to /usr/src/app/node_modules/node-sass/vendor/linux-x64-57/binding.node 
Caching binary to /home/gitlab-runner/.npm/node-sass/4.5.3/linux-x64-57_binding.node 
> uglifyjs-webpack-plugin@0.4.6 postinstall /usr/src/app/node_modules/uglifyjs-webpack-plugin 
> node lib/post_install.js 
> node-sass@4.5.3 postinstall /usr/src/app/node_modules/node-sass 
> node scripts/build.js Binary found at /usr/src/app/node_modules/node-sass/vendor/linux-x64-57/binding.node Testing binary Binary is fine 
npm WARN @ionic-native/splash-screen@3.12.1 requires a peer of @ionic-native/core@^3.6.0 but none was installed. 
npm WARN @ionic-native/status-bar@3.12.1 requires a peer of @ionic-native/core@^3.6.0 but none was installed. 
npm WARN angularfire2@5.0.0-rc.4 requires a peer of @angular/common@^5.0.0 but none was installed. 
npm WARN angularfire2@5.0.0-rc.4 requires a peer of @angular/core@^5.0.0 but none was installed. 
npm WARN angularfire2@5.0.0-rc.4 requires a peer of @angular/platform-browser@^5.0.0 but none was installed. 
npm WARN angularfire2@5.0.0-rc.4 requires a peer of @angular/platform-browser-dynamic@^5.0.0 but none was installed. 
npm WARN angularfire2@5.0.0-rc.4 requires a peer of rxjs@^5.5.2 but none was installed. 
npm WARN ionic2-super-tabs@4.1.5 requires a peer of ionic-angular@^3.9.2 but none was installed. 
npm WARN The package @ionic/app-scripts is included as both a dev and production dependency. 
added 1007 packages in 45.048s 
$ npm install --quiet --no-optional success 
$ npm run build npm info it worked if it ends with ok npm info using npm@5.3.0 npm info using node@v8.2.1 npm info lifecycle screenAddict@0.0.1~prebuild: screenAddict@0.0.1 npm info lifecycle screenAddict@0.0.1~build: screenAddict@0.0.1 
> screenAddict@0.0.1 build /usr/src/app 
> ionic-app-scripts build [18:33:28] ionic-app-scripts 2.1.4 [18:33:28] build dev started ... 
[18:33:28] clean started ... 
[18:33:28] clean finished in 1 ms [18:33:28] copy started ... 
[18:33:28] transpile started ... 
[18:33:33] typescript: node_modules/@firebase/database/dist/esm/src/api/Database.d.ts, line: 4 
Cannot find module '@firebase/app-types/private'. 
L3: import { FirebaseApp } from '@firebase/app-types'; 
[18:33:33] typescript: node_modules/@firebase/database/dist/esm/src/core/AuthTokenProvider.d.ts, line: 17 
L4: import { FirebaseService } from '@firebase/app-types/private'; Cannot find module '@firebase/app-types/private'. 
[18:33:33] typescript: node_modules/angularfire2/database/database.d.ts, line: 7 
[18:33:33] typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 3 L16: getToken(forceRefresh: boolean): Promise;
      L17:  addTokenChangeListener(listener: (token: string | null) => void): void;
      L18:  removeTokenChangeListener(listener: (token: string | null) => void): void;

            Cannot find namespace 'database'. 

       L6:  app: FirebaseApp;
       L7:  database: database.Database;
       L8:  constructor(app: FirebaseApp);

            Cannot find namespace 'firebase'. 

       L2:  import { Observable } from 'rxjs/Observable';
[18:33:33]  typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 3 
[18:33:33]  typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 12 
       L3:  export declare type FirebaseOperation = string | firebase.database.Reference | firebase.database.DataSnapsho
       L4:  export interface AngularFireList {

            Cannot find namespace 'firebase'. 

       L2:  import { Observable } from 'rxjs/Observable';
       L3:  port declare type FirebaseOperation = string | firebase.database.Reference | firebase.database.DataSnapshot;
       L4:  export interface AngularFireList {

            Cannot find namespace 'firebase'. 

[18:33:33]  typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 42 
[18:33:33]  typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 43 
      L11:  set(item: FirebaseOperation, data: T): Promise;
      L12:  push(data: T): firebase.database.ThenableReference;
      L13:  remove(item?: FirebaseOperation): Promise;

            Cannot find namespace 'firebase'. 

      L41:  export declare type Primitive = number | string | boolean;
      L42:  export declare type DatabaseSnapshot = firebase.database.DataSnapshot;
      L43:  export declare type DatabaseReference = firebase.database.Reference;

            Cannot find namespace 'firebase'. 

      L42:  export declare type DatabaseSnapshot = firebase.database.DataSnapshot;
[18:33:33]  typescript: node_modules/angularfire2/database/interfaces.d.ts, line: 44 
[18:33:33]  typescript: node_modules/angularfire2/database/list/audit-trail.d.ts, line: 7 
      L43:  export declare type DatabaseReference = firebase.database.Reference;
      L44:  export declare type DatabaseQuery = firebase.database.Query;

            Cannot find namespace 'firebase'. 

      L43:  export declare type DatabaseReference = firebase.database.Reference;
      L44:  export declare type DatabaseQuery = firebase.database.Query;
      L45:  export declare type QueryReference = DatabaseReference | DatabaseQuery;

            Cannot find namespace 'database'. 

       L6:  import 'rxjs/add/operator/map';
       L7:  tabaseQuery): (events?: ChildEvent[] | undefined) => Observable[]>;
       L8:  export declare function auditTrail(query: DatabaseQuery, events?: ChildEvent[]): Observable;
[18:33:33]  typescript: node_modules/angularfire2/database/list/state-changes.d.ts, line: 6 
[18:33:33]  typescript: node_modules/angularfire2/database/list/state-changes.d.ts, line: 7 
[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 5 

            Cannot find namespace 'database'. 

       L5:  import 'rxjs/add/operator/scan';
       L6:  DatabaseQuery): (events?: ChildEvent[] | undefined) => Observable>;
       L7:  export declare function stateChanges(query: DatabaseQuery, events?: ChildEvent[]): Observable>;

            Cannot find namespace 'database'. 

       L6:  export declare function createStateChanges(query: DatabaseQuery): (events?: ChildEvent[] | undefined) => Observable>;
       L7:  eChanges(query: DatabaseQuery, events?: ChildEvent[]): Observable>;

            Cannot find namespace 'firebase'. 

[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 8 
       L4:  export declare const FirebaseAppConfigToken: InjectionToken;
       L5:  export declare class FirebaseApp implements firebase.app.App {
       L6:      name: string;

            Cannot find namespace 'firebase'. 

       L7:  options: {};
       L8:  auth: () => firebase.auth.Auth;
       L9:  database: () => firebase.database.Database;

            Cannot find namespace 'firebase'. 

       L8:  auth: () => firebase.auth.Auth;
[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 9 
[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 10 
[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 11 
       L9:  database: () => firebase.database.Database;
      L10:  messaging: () => firebase.messaging.Messaging;

            Cannot find namespace 'firebase'. 

       L9:  database: () => firebase.database.Database;
      L10:  messaging: () => firebase.messaging.Messaging;
      L11:  storage: () => firebase.storage.Storage;

            Cannot find namespace 'firebase'. 

      L10:  messaging: () => firebase.messaging.Messaging;
[18:33:33]  typescript: node_modules/angularfire2/firebase.app.module.d.ts, line: 13 
      L11:  storage: () => firebase.storage.Storage;
      L12:  delete: () => Promise;

            Cannot find namespace 'firebase'. 

      L12:      delete: () => Promise;
      L13:      firestore: () => firebase.firestore.Firestore;

[18:33:33]  ionic-app-script task: "build" 
[18:33:33]  Error: Failed to transpile program 
Error: Failed to transpile program
    at new BuildError (/usr/src/app/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at /usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:137:20
    at Promise ()
    at transpileWorker (/usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:103:12)
    at Object.transpile (/usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:61:12)
    at buildProject (/usr/src/app/node_modules/@ionic/app-scripts/dist/build.js:97:78)
    at /usr/src/app/node_modules/@ionic/app-scripts/dist/build.js:47:16
    at 
npm info lifecycle screenAddict@0.0.1~build: Failed to exec build script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! screenAddict@0.0.1 build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the screenAddict@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/gitlab-runner/.npm/_logs/2018-01-07T18_33_33_999Z-debug.log
npm run build failed
Running after script...
$ run "clean-up"
Running Stage clean-up for Job: 5213190
ERROR: Job failed: exit status 1

#2

Don’t use this unless you’re willing to refactor all your types. Also, don’t use it at all if you’re using AF2.


#3

It’s not possible not to use firebase: as angularfire2 depends on firebase…
Here is the install command for angularfire2 : (from npmjs site
npm install firebase angularfire2 --save
If I uninstall firebase, my code don’t compile anymore with errors on angularfire2 needing firebase objects.

The question is, why do it build OK locally and I don’t have the same result on ionicPro.
It is very frustating…


#4

This might help

npm uninstall --save firebase 

in package.json change “firebase”: “^4.8.1”
to “4.8.0” then save package.json

reinstall firebase.

As to the why in regard to pro, I don’t know. I’m not a pro member.


#5

Thanks. As I said, it works locally but when uploading my code to IonicPro the build fails as if it has included version 4.8.1 of firebase ignoring the version that is in my package.json…


#6

Ohhhh ok. I see what you’re saying now. I misunderstood. No clue on the pro end, sorry.


#7

Did you manage to find out what it was? I’m encountering exactly the same issue :frowning:


#8

I had the same issue with Ionic Pro builds, solved it by changing the import expression:
from:
import * as firebase from 'Firebase';
to:
import firebase from 'firebase';

And it worked. Hope it helps.