Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'indexOf' of null on Cordova commands #815

Closed
tlancina opened this issue Mar 3, 2016 · 23 comments
Closed

Cannot read property 'indexOf' of null on Cordova commands #815

tlancina opened this issue Mar 3, 2016 · 23 comments

Comments

@erkkimon
Copy link

erkkimon commented Mar 3, 2016

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

@tlancina
Copy link
Contributor Author

tlancina commented Mar 3, 2016

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.

@erkkimon
Copy link

erkkimon commented Mar 3, 2016

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 cordova-ios@4.0.1
Error: Cannot read property 'indexOf' of null

@firdoussross
Copy link

I'm facing this issue as well, I'm running on node 4.2.6 and have tried ios@4.0.0 and ios@4.0.1 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 cordova-ios@4.0.1
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.

@tlancina
Copy link
Contributor Author

tlancina commented Mar 4, 2016

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

@erkkimon
Copy link

erkkimon commented Mar 4, 2016

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 cordova-ios@4.0.1
Error: Cannot read property 'indexOf' of null

@tlancina tlancina changed the title Cannot read property 'indexOf' of null on platform add Cannot read property 'indexOf' of null on Cordova commands Mar 6, 2016
@tlancina
Copy link
Contributor Author

tlancina commented Mar 6, 2016

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

https://issues.apache.org/jira/browse/CB-10675
nodejs/node#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 tlancina closed this as completed Mar 6, 2016
@erkkimon
Copy link

erkkimon commented Mar 6, 2016

Thanks, Tim!

@alcesar
Copy link

alcesar commented Mar 17, 2016

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.

@vance
Copy link

vance commented Jul 5, 2016

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.

@moneytree-doug
Copy link

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

@croulyoung
Copy link

@moneytree-doug me too

@ghost
Copy link

ghost commented Nov 10, 2016

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

@lucaslimasouza
Copy link

lucaslimasouza commented Jan 2, 2017

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

@tbergeron
Copy link

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

@gustavoferreirads
Copy link

gustavoferreirads commented Apr 27, 2017

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

@russcarver
Copy link

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

@illya13
Copy link

illya13 commented Aug 7, 2017

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 

@russcarver
Copy link

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

@Alejandroem
Copy link

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

@danielsotopino
Copy link

danielsotopino commented Aug 21, 2017

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

@sguzman
Copy link

sguzman commented Dec 12, 2017

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

@Story5
Copy link

Story5 commented Mar 20, 2018

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

@ionic-team ionic-team locked and limited conversation to collaborators Mar 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests