When I attempt to run my Cordova app using Visual Studio 2015 using Remote Device, I get an error \"SyntaxError: Unexpected token M\". Visual Studio is installed on windows
Found the solution to this!!!
Luckily I had an old backup of my project which didn't produce the "SyntaxError: Unexpected token M" when running it on the remote device. I used a compare tool to see the differences in files/folders. It turned out that the "remote_ios.json" file located in the plugins folder was corrupted. I deleted it and on the next run it generated a proper one and everything now works as expected. I can deploy to the iOS simulator on my mac as well as my iPhone.
I did notice a few more times that the file did get corrupted. So every time I just deleted the file and it got recreated and everything worked. Sounds like a bug in Visual Studio 2015.
Here's how my corrupted remote_os.json file looked like:
{
"prepare_queue": {
"installed": [],
"uninstalled": []
},
"config_munge": {
"files": {
"framework": {
"parents": {
"ImageIO.framework": [
{
"xml": true,
"count": 1
}
],
"CoreLocation.framework": [
{
"xml": false,
"count": 1
}
],
"CoreGraphics.framework": [
{
"xml": false,
"count": 4
}
],
"AssetsLibrary.framework": [
{
"xml": false,
"count": 3
}
],
"MobileCoreSe
and a more permanent fix for this issue (which worked for me):
Is to delete your plugins folder
Restore all of your plugins. (listed in your package.json
in an array called cordovaPlugins
)
Hint: Run cordova plugin ls
to have a list of what you need to add back in.
I use Ionic so I just used this command: ionic state restore --plugins
and voila problem solved for ever (I hope).
PS. FYI don't run cmd as administrator for this, it could be the cause of your issues with iOS apps...
Got to the root of the problem from Navid Harandi's answer.