"Error: Cannot read property ‘replace’ of undefined" for ios-sim

yeah it was old, if it aint broke don’t fix it, has been my approach on ionic as the more you update the more that breaks…

updated it to the current 5.1.0 but I still get the same issue…

ios-sim is part of Cordova, not Ionic directly. And obviously it is broken if you are getting errors :wink:
There is an issue here, but I am not sure if the solution is the correct one for you: TypeError: Cannot read property 'replace' of undefined (lib.js:282) · Issue #210 · ios-control/ios-sim · GitHub

What did you mean by that by the way? Nothing additional?

Another idea from here: https://github.com/phonegap/ios-sim/issues/210

Check if you have a local ios-sim maybe that could clash with the global one. (Look into node_modules folder)

Worked Great Thanks!

I removed the ios-sim directory inside myApp/platforms/ios/cordova/node_modules and now it’s working. Now it uses the global installed one i guess. Thanks! :slight_smile:

3 Likes

Do you remember or can check when (and why) ios-sim got added locally (maybe via package.json blame in git)?

Update: Just realized that it’s in /platforms/ios/cordova/ - and there is no package.json there.
Update 2: Got it: https://github.com/apache/cordova-ios/blob/master/package.json#L49

So here is the “official” fix from someone Cordova team:

in your project folder root, do cd platforms/ios/cordova && npm install ios-sim

TypeError: Cannot read property 'replace' of undefined (lib.js:282) · Issue #210 · ios-control/ios-sim · GitHub

(Which also means: You can/should get rid of the global install via npm uninstall -g ios-sim)

17 Likes

@shazron added an even better (inofficial) “solution” to use, that also works if you readd the ios platform:

In the meantime, I cherry-picked the ios-sim fix only and applied it to cordova-ios@4.4.0
To use:
cordova platform add https://github.com/apache/cordova-ios.git#4.4.0-ios-sim

This is not an official release of Apache Cordova.

TypeError: Cannot read property 'replace' of undefined (lib.js:282) · Issue #210 · ios-control/ios-sim · GitHub

3 Likes

Same Issue

global packages:

@ionic/cli-plugin-proxy : 1.3.0
@ionic/cli-utils        : 1.3.0-alpha.ba34a861
Cordova CLI             : 7.0.1 
Ionic CLI               : 3.3.0-alpha.ba34a861

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.3.0-alpha.ba34a861
@ionic/cli-plugin-ionic-angular : 1.3.0-alpha.ba34a861
Cordova Platforms               : android 6.2.2 ios 4.4.0
Ionic Framework                 : ionic-angular 3.2.1

System:

Node       : v7.9.0
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 5.1.0 
npm        : 5.0.0

The solution for me was run ionic cordova build ios and after open Xcode to run in a simulator o in a device. is more slow but work for me, I hope Cordova release the solution in the next days.

1 Like

I did the steps from Sujan12 and it works, thank you.

1 Like

Why don’t you do this: “Error: Cannot read property ‘replace’ of undefined” for ios-sim

I followed the comment here and it worked great: https://github.com/phonegap/ios-sim/issues/210#issuecomment-307590994

cd platforms/ios/node_modules
npm i ios-sim@latest
2 Likes

hi, update all angular dependency as well as ionic cli

Hi I had the same issue. This fixed it form me:

4 Likes

This works for me too

Thank you! This took care of it for me as well.

Is anyone getting this problem when doing run android? Im getting this exact same error for android but not ios? Doing run ios works fine. All my sdk and jdks are properly configured in bash …

Yes, first result when you search for the error message in the forum:

1 Like

I am having the same problem when trying to emulate Android, I decided as follows:
I opened the android emulator by AndroidStudio
Then I ran the emulate android cordova command

And pammm worked

Worked for me :slight_smile: thx