SyntaxError: Unexpected token M (when running cordova project from Visual Studio 2015)

后端 未结 2 1601
暗喜
暗喜 2021-01-05 17:20

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

相关标签:
2条回答
  • 2021-01-05 17:51

    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
    
    0 讨论(0)
  • 2021-01-05 18:12

    The solution is

    and a more permanent fix for this issue (which worked for me):

    1. Is to delete your plugins folder

    2. 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.

    0 讨论(0)
提交回复
热议问题