I’m almost ripping my hair out with that mistake. Everything should be very simple but …
It seems that everything started to go wrong after including firebase and angualarfire2
Has anyone had this problem yet?
I tried this but it did not solve the problem;
I tried to help here too but I did not succeed
CONSOLE:
[23:36:47] ionic-app-scripts 0.0.46
[23:36:47] watch started …
[23:36:47] build dev started …
[23:36:47] clean started …
[23:36:47] clean finished in 3 ms
[23:36:47] copy started …
[23:36:47] transpile started … [23:36:50] build dev failed: Cannot read property ‘indexOf’ of undefined
[23:36:50] copy: Error copying “D:\Apps\ … \src\assets” to
“D:\Apps\ … \www\assets”
[23:36:50] copy: Error copying “D:\Apps\ … \node_modules\ionicons\dist
fonts” to
“D:\Apps\ … \www\assets\fonts”
[23:36:50] copy: Error copying “D:\Apps\ … \node_modules\ionic-angular
fonts” to
“D:\Apps\ … \www\assets\fonts”
[23:36:50] copy finished in 3.02 s
[23:36:50] watch ready in 3.11 s
[23:36:50] dev server running: http://localhost:8100/
D:\CgMobile>ionic serve --debug
Running 'serve:before' npm script before serve
> cgmobile2@0.1.0 watch D:\CgMobile
> ionic-app-scripts watch
[12:49:46] ionic-app-scripts 0.0.46
[12:49:46] watch started ...
[12:49:46] build dev started ...
[12:49:46] clean started ...
[12:49:46] clean finished in 2 ms
[12:49:46] copy started ...
[12:49:46] transpile started ...
[12:49:59] build dev failed: Cannot read property 'indexOf' of undefin
ed
[12:50:00] copy: Error copying "D:\CgMobile\node_modules\ionicons\dist
\fonts" to "D:\CgMobile\www\assets\fonts"
[12:50:00] copy: Error copying "D:\CgMobile\node_modules\ionic-angular
\fonts" to "D:\CgMobile\www\assets\fonts"
[12:50:00] copy finished in 14.46 s
[12:50:00] watch ready in 14.60 s
And then the Ionic Info:
D:\CgMobile>ionic info
Your system information:
ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.13
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.46
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.1
Xcode version: Not installed
Same here: All of a sudden my project stopped building with the same error. I have rm -r node_modules and npm cache clean and then npm install. Same error. HELP anyone?
build dev failed: Cannot read property ‘indexOf’ of undefined MEM: 231.6MB
[ DEBUG! ] TypeError: Cannot read property ‘indexOf’ of undefined at loadDiagnostic
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:47:27) at
/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:12:16 at
Array.map (native) at Object.runTypeScriptDiagnostics
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/logger/logger-typescript.js:11:26) at
/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/transpile.js:92:47 at transpileWorker
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/transpile.js:62:12) at Object.transpile
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/transpile.js:26:12) at buildDev
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/build.js:84:24) at buildWorker
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/build.js:35:12) at Object.build
(/Users/emgould/Dev/testIonic/node_modules/@ionic/app-scripts/dist/build.js:19:12)
There is not enough info given by “ionic serve --debug”, Cannot read property ‘indexOf’ of undefined is always fired by Ionic when there is a crash on build.
Can you run “ionic build browser” and copy the log here ?
“browser” doesn’t matter, you can use android or any plateform you like
[23:56:01] ionic-app-scripts 0.0.46
[23:56:01] build prod started …
[23:56:01] clean started …
[23:56:01] clean finished in 3 ms
[23:56:01] copy started …
[23:56:01] ngc started …
[23:56:01] copy: Error copying “D:\Apps\ … \src\assets” to “D:\Apps\ … \www\assets”
[23:56:01] copy: Error copying “D:\Apps\ … \node_modules\ionic-angular\fonts” to “D:\Apps\ … \www\assets\fonts”
[23:56:01] copy finished in 403 ms
[23:56:17] Error: Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:12:9
[23:56:17] Duplicate identifier ‘Promise’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:17:9
[23:56:17] Duplicate identifier ‘Promise_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:130:9
[23:56:17] Duplicate identifier ‘EmailAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:135:9
[23:56:17] Duplicate identifier ‘EmailAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:144:9
[23:56:17] Duplicate identifier ‘FacebookAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:148:9
[23:56:17] Duplicate identifier ‘FacebookAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:153:9
[23:56:17] Duplicate identifier ‘GithubAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:157:9
[23:56:17] Duplicate identifier ‘GithubAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:162:9
[23:56:17] Duplicate identifier ‘GoogleAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:167:9
[23:56:17] Duplicate identifier ‘GoogleAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:172:9
[23:56:17] Duplicate identifier ‘TwitterAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:177:9
[23:56:17] Duplicate identifier ‘TwitterAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:181:8
[23:56:17] Duplicate identifier ‘UserCredential’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:339:8
[23:56:17] Duplicate identifier ‘StringFormat’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:340:7
[23:56:17] Duplicate identifier ‘StringFormat’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:347:8
[23:56:17] Duplicate identifier ‘TaskEvent’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:348:7
[23:56:17] Duplicate identifier ‘TaskEvent’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:352:8
[23:56:17] Duplicate identifier ‘TaskState’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:353:7
[23:56:17] Duplicate identifier ‘TaskState’.
[23:56:17] Error at D:/Apps/ …/node_modules/angularfire2/node_modules/firebase/firebase.d.ts:390:3
[23:56:17] Duplicate identifier ‘export=’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:12:9
[23:56:17] Duplicate identifier ‘Promise’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:17:9
[23:56:17] Duplicate identifier ‘Promise_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:132:9
[23:56:17] Duplicate identifier ‘EmailAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:137:9
[23:56:17] Duplicate identifier ‘EmailAuthProvider_Instance’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:146:9
[23:56:17] Duplicate identifier ‘FacebookAuthProvider’.
[23:56:17] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:150:9
[23:56:17] Duplicate identifier ‘FacebookAuthProvider_Instance’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:156:9
[23:56:18] Duplicate identifier ‘GithubAuthProvider’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:160:9
[23:56:18] Duplicate identifier ‘GithubAuthProvider_Instance’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:166:9
[23:56:18] Duplicate identifier ‘GoogleAuthProvider’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:171:9
[23:56:18] Duplicate identifier ‘GoogleAuthProvider_Instance’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:177:9
[23:56:18] Duplicate identifier ‘TwitterAuthProvider’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:182:9
[23:56:18] Duplicate identifier ‘TwitterAuthProvider_Instance’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:187:8
[23:56:18] Duplicate identifier ‘UserCredential’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:358:8
[23:56:18] Duplicate identifier ‘StringFormat’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:359:7
[23:56:18] Duplicate identifier ‘StringFormat’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:366:8
[23:56:18] Duplicate identifier ‘TaskEvent’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:367:7
[23:56:18] Duplicate identifier ‘TaskEvent’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:371:8
[23:56:18] Duplicate identifier ‘TaskState’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:372:7
[23:56:18] Duplicate identifier ‘TaskState’.
[23:56:18] Error at D:/Apps/ …/node_modules/firebase/firebase.d.ts:409:3
[23:56:18] Duplicate identifier ‘export=’.
[23:56:18] ngc failed
[23:56:18] ionic-app-script task: “build”
[23:56:18] Error: Error
npm ERR! Windows_NT 10.0.14393
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “run” “ionic:build” "–"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! ionic-hello-world@ ionic:build: ionic-app-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-hello-world@ ionic:build script ‘ionic-app-scripts build’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ionic-hello-world package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs ionic-hello-world
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls ionic-hello-world
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\Apps\ … \npm-debug.log
[23:56:17] Error: Error at D:/Apps/ .../node_modules/angularfire2/node_modules/firebase/firebase.d.ts:12:9
[23:56:17] Duplicate identifier 'Promise'.
[23:56:17] Error at D:/Apps/ .../node_modules/firebase/firebase.d.ts:12:9
[23:56:17] Duplicate identifier 'Promise'.
It’s because, as you can see, angularfire2 has the depdency “firebase”, and you installed “firebase” as a module too, as I presume ? If it’s not the case, it’s angularfire2’s fault.
@nilton_felicio I think your solution might have unintended consequences, and it wasn’t what @Shocoben suggested. I agree that posting on GitHub would be a good idea, because angularfire2 is still changing a lot.
The biggest issue for me was to handle both auth and upload/download, when angularfire2 can’t do upload/download yet. I dealt with this by following the angularfire2 docs for auth, and by using @Inject(FirebaseApp) firebaseApp: firebase.app.App when I wanted to upload or download. This gave me a typed object I could use instead of running into duplicate call problems from using firebase – for example var gsReference = firebaseApp.storage().refFromURL('gs://firebasestoragefolder/images/imagename.jpg');
See the second code snippet at this SO answer for a more complete example.
I don’t know whether that will eventually break, but I expect there will be a better way to do things after angularfire2 wraps Firebase storage functions.