Ionic production build fails.
Version info
Angular: 4.1.3 Firebase: 4.3.0 AngularFire: 4.0.0-rc.2 Other (e.g. Ionic/Cordova, Node, browser, operating system): ionic 3.9.2
How to reproduce these conditions
Failing test unit, Plunkr, or JSFiddle demonstrating the problem
Steps to set up and reproduce Started a new project following the guide at [https://github.com/angular/angularfire2/blob/master/docs/Auth-with-Ionic3-Angular4.md]
Doing a dev build with 'ionic build' or testing the app with 'ionic serve' works fine. But as soon as I add the '--prod' switch to the build command, it fails.
Sample data and security rules
<-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->
Debug output
Error: ./src/pages/login/login.ngfactory.js Module not found: Error: Can't resolve '../../../angularfire2/auth' in 'D:\Makin gChoices.be\MobileApps\Apps\OHAMBO\src\pages\login' resolve '../../../angularfire2/auth' in 'D:\MakingChoices.be\MobileApps\Apps\OHA MBO\src\pages\login' using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.jso n (relative path: ./src/pages/login) Field 'browser' doesn't contain a valid alias configuration after using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\packa ge.json (relative path: ./src/pages/login) using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.j son (relative path: ./angularfire2/auth) no extension Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st .js Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts doesn't exist as directory D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] @ ./src/pages/login/login.ngfactory.js 39:0-55 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./src/app/app.module.ngfactory.js Module not found: Error: Can't resolve '../../angularfire2/auth' in 'D:\MakingCh oices.be\MobileApps\Apps\OHAMBO\src\app' resolve '../../angularfire2/auth' in 'D:\MakingChoices.be\MobileApps\Apps\OHAMBO \src\app' using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.jso n (relative path: ./src/app) Field 'browser' doesn't contain a valid alias configuration after using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\packa ge.json (relative path: ./src/app) using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.j son (relative path: ./angularfire2/auth) no extension Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st .js Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts doesn't exist as directory D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] @ ./src/app/app.module.ngfactory.js 32:0-52 @ ./src/app/main.ts,./src/app/app.component.ngfactory.js Module not found: Error: Can't resolve '../../angularfire2/auth' in 'D:\MakingCh oices.be\MobileApps\Apps\OHAMBO\src\app' resolve '../../angularfire2/auth' in 'D:\MakingChoices.be\MobileApps\Apps\OHAMBO \src\app' using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.jso n (relative path: ./src/app) Field 'browser' doesn't contain a valid alias configuration after using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\packa ge.json (relative path: ./src/app) using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.j son (relative path: ./angularfire2/auth) no extension Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st .js Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js doesn't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts doesn't exist as directory D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth doesn't exi st [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.js] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth.ts] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\auth] @ ./src/app/app.component.ngfactory.js 25:0-52 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./src/app/app.module.ngfactory.js Module not found: Error: Can't resolve '../../angularfire2/database' in 'D:\Maki ngChoices.be\MobileApps\Apps\OHAMBO\src\app' resolve '../../angularfire2/database' in 'D:\MakingChoices.be\MobileApps\Apps\OH AMBO\src\app' using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.jso n (relative path: ./src/app) Field 'browser' doesn't contain a valid alias configuration after using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\packa ge.json (relative path: ./src/app) using description file: D:\MakingChoices.be\MobileApps\Apps\OHAMBO\package.j son (relative path: ./angularfire2/database) no extension Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database doesn't exist .js Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database.js does n't exist .ts Field 'browser' doesn't contain a valid alias configuration D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database.ts does n't exist as directory D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database doesn't exist [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database.js] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database.ts] [D:\MakingChoices.be\MobileApps\Apps\OHAMBO\angularfire2\database] @ ./src/app/app.module.ngfactory.js 31:0-56 @ ./src/app/main.ts ** Errors in the JavaScript console **
** Output from firebase.database().enableLogging(true); **
** Screenshots **
Expected behavior
A good production build.
Actual behavior
Production build fails
same issue with 5.0.0-rc.3 and app-scripts nightly.
same with "angularfire2": "^5.0.0-rc.2",
@Gabrielr47 This is should be fixed with the latest, if not file the issue with Ionic. They're good people who can help :)
it is fixed now in "angularfire2": "^5.0.0-rc.3",.... just run "npm install angularfire2 firebase promise-polyfill --save" and then run - "ionic cordova build android --prod "
I had this problem too, I think... At least something very similar to it.
The problem started happening in my Ionic 3 project after I updated firebase to 4.6.0 and angularfire2 to 5.0.0-rc.3 (so that I could use Firestore). Everything worked fine with dev builds but when I tried to push a production build it seems like webpack failed.
Here's my working package configuration, after much pain...
"@angular/common": "4.4.4",
"@angular/compiler": "4.4.4",
"@angular/compiler-cli": "4.4.4",
"@angular/core": "4.4.4",
"@angular/forms": "4.4.4",
"@angular/http": "4.4.4",
"@angular/platform-browser": "4.4.4",
"@angular/platform-browser-dynamic": "4.4.4",
"@ionic-native/core": "3.12.1",
"@ionic-native/splash-screen": "3.12.1",
"@ionic-native/status-bar": "3.12.1",
"@ionic/app-scripts": "3.0.1",
"@ionic/cli-plugin-ionic-angular": "1.4.1",
"@ionic/storage": "2.0.1",
"angularfire2": "5.0.0-rc.3",
"express": "^4.15.3",
"firebase": "^4.6.0",
"ionic": "^3.15.2",
"ionic-angular": "^3.8.0",
"ionicons": "3.0.0",
"promise-polyfill": "6.0.2",
"rxjs": "5.4.3",
"sw-toolbox": "3.6.0",
"typescript": "2.3.4",
"zone.js": "0.8.18"
I think node/npm version has something to do with this too. Started with 6.9.0/3.10.8 (prod build failing) but ended up with 6.11.5/3.10.10 (working) However, I think recently I needed to switch my node/npm version to get a stencil.js project working, so the version I used to update firebase/angularfire2 might not have been 6.9.0 (sorry, kinda lost track)
Any news on this? I'm also having this issue.
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/compiler-cli": "4.1.3",
"@angular/core": "4.1.3",
"firebase": "^4.6.0",
"angularfire2": "^5.0.0-rc.3",
"ionic": "3.16.0",
"ionic-angular": "3.6.0",
"promise-polyfill": "^6.0.2"
@allanpoppe latest everything (including devDependencies) working for me. I was earlier having this issue but in last couple of weeks tried again and am not.
@San10694 could you post your dependencies from package.json file and "ionic info" of your project here?
I just moved to Firestore + angularfire(5.0.0-rc.3). It works great and android build also works.
@sloznjak yes bro ,
"dependencies": { "@angular/common": "4.4.3", "@angular/compiler": "4.4.3", "@angular/compiler-cli": "4.4.3", "@angular/core": "4.4.3", "@angular/forms": "4.4.3", "@angular/http": "4.4.3", "@angular/platform-browser": "4.4.3", "@angular/platform-browser-dynamic": "4.4.3", "@angular/platform-server": "2.2.1", "@angular/tsc-wrapped": "^4.4.5", "@firebase/webchannel-wrapper": "0.2.2", "@ionic/storage": "2.0.1", "ionic-angular": "3.7.1", "@types/firebase": "^2.4.32", "angular-animate": "^1.6.1", "angular2-moment": "^1.3.3", "angularfire2": "^5.0.0-rc.3", "firebase": "^4.6.0" ] and here is my ionic-info ---->
cli packages:
@ionic/cli-utils : 1.15.2
ionic (Ionic CLI) : 3.15.2
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.0.0
Cordova Platforms : none
Ionic Framework : ionic-angular 3.7.1
System:
Android SDK Tools : 25.2.5
Node : v6.10.1
npm : 3.10.10
OS : Windows 10
hope it will help you .
@San10694 Thanks a lot! That helped 😃
Solved the issue by updating @angular/* and ionic-angular dependencies.
@allanpoppe which command did you run to update all the dependencies
@kaushikred actually I did it manually...
npm install --save @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] @angular/[email protected] [email protected]
After that, I also had to update some other packages because npm threw some WARNs.
@allanpoppe thanks but I just updated so many things it's just may I know which version of typescript and rxjs was in dependencie
I also updated rxjs, zone.js and typescript.
"promise-polyfill": "6.0.2", "rxjs": "5.4.3", "zone.js": "0.8.18"
"@ionic/app-scripts": "2.1.3", "ionic": "3.17.0", "typescript": "2.3.4"
@San10694 Thanks a lot! lt worked!
I am getting the same error message but NOT using ionic at all so I guess somehow I've recreated this problem. Can someone quickly describe how this issue was addressed in Ionic?
Note I am using Typescript and the following deps in package.json:
"dependencies": {
"@firebase/app": "^0.1.5",
"firebase": "^4.8.1",
},
"peerDependencies": {
"@firebase/database-types": "0.1.0",
"@firebase/app-types": "^0.1.0",
"@firebase/auth": "^0.3.1",
"@firebase/auth-types": "^0.1.0"
},
"devDependencies": {
"@firebase/app-types": "^0.1.0",
"@firebase/auth": "^0.3.1",
"@firebase/auth-types": "^0.1.0",
"@firebase/database-types": "0.1.0",
note: I did remove the non firebase deps for brevity
I do find it very confusing with the source code in @firebase versus that in firebase. I originally figured @firebase was just TS typings but there is implementation code there too.
Also note the full stack trace of the error I'm getting:
TypeError: Cannot read property 'databaseURL' of undefined
at RepoManager.databaseFromApp (/Users/ken/mine/forest-fire/abstracted-client/node_modules/@firebase/database/dist/cjs/src/src/core/RepoManager.ts:82:45)
at Object.instance.INTERNAL.registerService.Reference [as database] (/Users/ken/mine/forest-fire/abstracted-client/node_modules/@firebase/database/dist/index.node.ts:60:53)
at FirebaseAppImpl._getService (/Users/ken/mine/forest-fire/abstracted-client/node_modules/@firebase/app/dist/cjs/src/dist/cjs/src/firebaseApp.ts:160:8)
at FirebaseAppImpl.(anonymous function) [as database] (/Users/ken/mine/forest-fire/abstracted-client/node_modules/@firebase/app/dist/cjs/src/dist/cjs/src/firebaseApp.ts:375:25)
at DB.connect (/Users/ken/mine/forest-fire/abstracted-client/src/db.ts:76:40)
at new DB (/Users/ken/mine/forest-fire/abstracted-client/src/db.ts:39:12)
at Suite.describe (/Users/ken/mine/forest-fire/abstracted-client/test/db-spec.ts:39:14)
at Object.create (/Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/lib/interfaces/common.js:114:19)
at context.describe.context.context (/Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/lib/interfaces/bdd.js:44:27)
at Object.<anonymous> (/Users/ken/mine/forest-fire/abstracted-client/test/db-spec.ts:37:1)
at Module._compile (module.js:643:30)
at Module.m._compile (/Users/ken/mine/forest-fire/abstracted-client/node_modules/ts-node/src/index.ts:392:23)
at Module._extensions..js (module.js:654:10)
at Object.require.extensions.(anonymous function) [as .ts] (/Users/ken/mine/forest-fire/abstracted-client/node_modules/ts-node/src/index.ts:395:12)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/Users/ken/mine/forest-fire/abstracted-client/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
AngularFire 4.0.0-rc.1 does not seem to have this issue, 4.0.0-rc.2 does. I rolled back for now.
how do I do that?