Ionic-cli: Cannot read property 'indexOf' of null on Cordova commands

Created on 3 Mar 2016  路  23Comments  路  Source: ionic-team/ionic-cli

Most helpful comment

I had this issue when there was a problem in the config.xml file - we'd left out the * following file in the following statement

<access origin="file:*" launch-external="true"/>

All 23 comments

This is the output of "ionic info".

$ ionic info

Your system information:

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.1
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v5.7.0
Xcode version: Xcode 7.2.1 Build version 7C1002

Thanks! Was this error on an existing project? And if so, had you updated node from the time you started the project? Someone suggested that it was related to node v5.7.0.

Yes, this problem has probably started to occur with the Node v5.7.0 update. I don't remember exactly when I updated my Node, but I upgrade my tools quite often.

And in my case, the error occurs in an existing project created months ago. New projects don't seem to suffer from similar symptoms. I did test it, and new projects added iOS platform with no problems with the tool set that failed to add iOS platform to my existing project.

I got around this issue temporarily by downgrading my Node to v5.4.0 using NVM, so it seems quite obvious the problem lies in Node v5.7.0.

This is not the original error message, but I replicated the original scenario by reverting back to Node v5.7.0 (nvm deactivate). Then adding iOS platform results the following error message:

$ ionic platform add ios
Updated the hooks directory to have execute permissions
Running command: /Users/tom/Github/level-app/hooks/before_platform_add/init_directories.js /Users/tom/Github/level-app
Adding ios project...
iOS project created with [email protected]
Error: Cannot read property 'indexOf' of null

I'm facing this issue as well, I'm running on node 4.2.6 and have tried [email protected] and [email protected] platforms and they both give the same error. Here's my ionic info output:

$ ionic platform add ios
Updated the hooks directory to have execute permissions
Adding ios project...
iOS project created with [email protected]
Error: Cannot read property 'indexOf' of null


$聽ionic info
Your system information:

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.2.6
Xcode version: Xcode 7.2.1 Build version 7C1002

This happens on existing project. The project was working fine before. I did try re-cloning my git repo and adding the platform again, but it give the same result.

Hmm, still not able to reproduce. Does running cordova platform add ios error as well?

Yes, it also fails to run.

(tom @ )-(~/Github/level-app)
(master) $ ionic info

Your system information:

Cordova CLI: 6.0.0
Gulp version:  CLI version 3.9.0
Gulp local:   Local version 3.9.1
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v5.7.0
Xcode version: Xcode 7.2.1 Build version 7C1002

(tom @ )-(~/Github/level-app)
(master) $ cordova platform add ios
Running command: /Users/tom/Github/level-app/hooks/before_platform_add/init_directories.js /Users/tom/Github/level-app
Adding ios project...
iOS project created with [email protected]
Error: Cannot read property 'indexOf' of null

Looks like this is a Node bug, to be fixed in 5.7.1:

https://issues.apache.org/jira/browse/CB-10675
https://github.com/nodejs/node/issues/5393

Going to close as it's not an Ionic issue, but please feel free to post here if you're still having issues, thanks!

Thanks, Tim!

I first face this issue when my info were:

Cordova CLI: 6.0.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.5
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.3.0
Xcode version: Xcode 7.2 Build version 7C68

Upgrading node to 5.7.1 does not change the situation, so I'm a little bit confused now.

EDITED: Something useful that i've found is that the trouble, in my case, is related to the presence of the iOS platform. Removing it makes the android composition works just fine again.

upgrading does not fix this. project was working, randomly stopped. I used NVM to jump between several versions of node, none of which worked. This is totally messed up, cannot compile at all, and I've been working fine for months. I tried removing and adding the platform. nope.

Same issue, and I tried everything that @vance said.

@moneytree-doug me too

I had this issue when there was a problem in the config.xml file - we'd left out the * following file in the following statement

<access origin="file:*" launch-external="true"/>

Ionic platforma add android

Your system information:

Cordova CLI: 6.0.0
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.13
Node Version: v5.7.1
Xcode version: Not installed

ERROR:


Upgrade warning - for the CLI to run correctly,
it is highly suggested to upgrade the following:

Please update your Cordova CLI to version >=4.2.0 npm install -g cordova


Updated the hooks directory to have execute permissions
Creating android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.studioapp971278
Name: studioApp
Android target: android-19
Copying template files...
Project successfully created.
Running command: /home/lucaslima/worspace/studioApp/hooks/after_prepare/010_add_platform_class.js /home/lucaslima/worspace/studioApp
add to body class: platform-android
Installing "cordova-plugin-console" for android
Installing "cordova-plugin-device" for android
Installing "cordova-plugin-splashscreen" for android
TypeError: Cannot read property 'indexOf' of undefined

I'm getting the same error as the user above me. Any idea how to fix this?

To solve this problem just move all <access origin="file:..." or <allow-navigation href="file:.." /> under <platform name="android"> in config.xml

None of this has worked for me.

cli packages: (/Confidential/GF/Grassified-App/node_modules)

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-plugin-proxy         : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.5.2

System:

    Android SDK Tools : 26.0.2
    Node              : v8.1.4
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b
    ios-deploy        : 1.9.1
    ios-sim           : 6.0.0
    npm               : 5.0.3

Having issue as well:

cli packages: (/mobile/node_modules)

    @ionic/cli-plugin-cordova       : 1.6.2
    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : none
    Ionic Framework    : ionic-angular 3.6.0

System:

    Android SDK Tools : 26.0.2
    Node              : v6.11.2
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy        : 1.9.1 
    npm               : 3.10.10 

I fixed this by removing the lines that were being automatically added to my config.xml such as <allow-navigation href="http://:8100" />

To me my config.xml was emtpy so I fixed it and the problem is gone

Fixed it by removing this line:
<allow-navigation href="http://:8100" />

Confirming that this fixed the issue for me, which manifested when trying to launch iOS emulator and adding cordova plugins

Fixed by removeing
<allow-navigation href="http://:8100" />
Thanks @russcarver

Was this page helpful?
0 / 5 - 0 ratings