Ionic Serve - build dev failed: Cannot read property 'indexOf' of undefined #544

richardshergold opened this Issue Dec 14, 2016 · 4 comments


None yet

3 participants

richardshergold commented Dec 14, 2016 edited

I have upgraded to the latest CLI and AppScripts and am now having problems with my project build. The project was building and serving fine yesterday so if there's no easy fix to the problems I am seeing today, how do I revert back to a previous version of CLI and App Scripts?

I followed the instructions here for 0.0.47:

and now when I attempt an ionic serve I get:

[10:15:23] ionic-app-scripts 0.0.47
[10:15:24] watch started ...
[10:15:24] build dev started ...
[10:15:24] clean started ...
[10:15:24] clean finished in 1 ms
[10:15:24] copy started ...
[10:15:24] transpile started ...
[10:15:27] build dev failed: Cannot read property 'indexOf' of undefined
[10:15:27] dev server running: http://localhost:8100/

[10:15:27] copy finished in 3.19 s
[10:15:27] watch ready in 3.21 s

My build folder remains empty so in the browser console I see a bunch of "failed to load resource errors" for build/main.js etc.

ionic info

Your system information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3-201611211919
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: 1.9.0
ios-sim version: 5.0.11
OS: macOS Sierra
Node Version: v7.2.1
Xcode version: Xcode 8.1 Build version 8B62


"name": "cargomessenger",
"description": "cargomessenger",
"license": "Apache-2.0",
"scripts": {
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/storage": "1.1.6",
"ionic-angular": "2.0.0-rc.3",
"ionic-native": "2.2.3",
"ionicons": "3.0.0",
"rxjs": "5.0.0-beta.12",
"zone.js": "0.6.26",
"angularfire2": "2.0.0-beta.6",
"firebase": "^3.6.1"
"devDependencies": {
"@ionic/app-scripts": "0.0.45",
"typescript": "2.0.9"
"cordovaPlugins": [
"locator": "",
"id": "com.verso.cordova.clipboard"
"locator": "",
"id": "cordova-plugin-splashscreen"
"cordovaPlatforms": [

if I run ionic build ios I get errors too (of course) and the generated log is:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'run',
1 verbose cli 'ionic:build',
1 verbose cli '--' ]
2 info using npm@3.10.10
3 info using node@v7.2.1
4 verbose run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
5 info lifecycle cargomessenger@~preionic:build: cargomessenger@
6 silly lifecycle cargomessenger@~preionic:build: no script for preionic:build, continuing
7 info lifecycle cargomessenger@~ionic:build: cargomessenger@
8 verbose lifecycle cargomessenger@~ionic:build: unsafe-perm in lifecycle true
9 verbose lifecycle cargomessenger@~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/richardshergold/Ionic Projects/cmx-messenger-ionic/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle cargomessenger@~ionic:build: CWD: /Users/richardshergold/Ionic Projects/cmx-messenger-ionic
11 silly lifecycle cargomessenger@~ionic:build: Args: [ '-c', 'ionic-app-scripts build' ]
12 silly lifecycle cargomessenger@~ionic:build: Returned: code: 1 signal: null
13 info lifecycle cargomessenger@~ionic:build: Failed to exec ionic:build script
14 verbose stack Error: cargomessenger@ ionic:build: ionic-app-scripts build
14 verbose stack Exit status 1
14 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:885:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid cargomessenger@
16 verbose cwd /Users/richardshergold/Ionic Projects/cmx-messenger-ionic
17 error Darwin 16.1.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ionic:build" "--"
19 error node v7.2.1
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error cargomessenger@ ionic:build: ionic-app-scripts build
22 error Exit status 1
23 error Failed at the cargomessenger@ ionic:build script 'ionic-app-scripts build'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the cargomessenger package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error ionic-app-scripts build
23 error You can get information on how to open an issue for this project with:
23 error npm bugs cargomessenger
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls cargomessenger
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]


FIXED - I had Firebase as a dependency as well as AngularFire - removing Firebase from package.json fixed the issue.


I tried removing firebase from package.json, but then the app will crash trying to reference firebase in webpack. Is there another solution?


Thanks guillefd for the suggestion. I tried it and had the same problem. Found this solution and it worked:

"Delete the firebase.d.ts in the folder node_modules\firebase"

driftyco/ionic-cli#1713 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment