ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Cannot read property 'indexOf' of null on Cordova commands

Open tlancina opened this issue 10 years ago • 22 comments

https://forum.ionicframework.com/t/error-adding-ios-platform-error-indexof-undefined-solved/45234 https://forum.ionicframework.com/t/getting-error-while-adding-platform-ios-in-ionic/41657 http://stackoverflow.com/questions/35747292/ionic-cli-error-error-cannot-read-property-indexof-of-null-on-terminal

tlancina avatar Mar 03 '16 16:03 tlancina

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

erkkimon avatar Mar 03 '16 17:03 erkkimon

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.

tlancina avatar Mar 03 '16 20:03 tlancina

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

erkkimon avatar Mar 03 '16 21:03 erkkimon

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.

firdoussross avatar Mar 04 '16 01:03 firdoussross

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

tlancina avatar Mar 04 '16 15:03 tlancina

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

erkkimon avatar Mar 04 '16 16:03 erkkimon

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!

tlancina avatar Mar 06 '16 14:03 tlancina

Thanks, Tim!

erkkimon avatar Mar 06 '16 14:03 erkkimon

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.

alcesar avatar Mar 17 '16 18:03 alcesar

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.

vance avatar Jul 05 '16 08:07 vance

@moneytree-doug me too

croulyoung avatar Sep 10 '16 10:09 croulyoung

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"/>

ghost avatar Nov 10 '16 11:11 ghost

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

lucaslimasouza avatar Jan 02 '17 02:01 lucaslimasouza

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

tbergeron avatar Mar 15 '17 17:03 tbergeron

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

gustavoferreirads avatar Apr 27 '17 00:04 gustavoferreirads

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

russcarver avatar Aug 06 '17 04:08 russcarver

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 

illya13 avatar Aug 07 '17 14:08 illya13

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

russcarver avatar Aug 07 '17 15:08 russcarver

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

Alejandroem avatar Aug 16 '17 00:08 Alejandroem

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

danielsotopino avatar Aug 21 '17 20:08 danielsotopino