问题
I have cordova 3.3 installed (in 3.2, have the same error) and when i want to add or remove a plugin the system show this error:
>>cordova plugin add org.apache.cordova.network-information
Fetching plugin from "org.apache.cordova.network-information"...
Starting installation of "org.apache.cordova.network-information" for android
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
SyntaxError: Unexpected token
I check the path and is correct:
echo $PATH
/usr/local/bin:/Users/manuelcm/Documents/sdk_android/platform-tools:
/Users/manuelcm/Documents/sdk_android/tools:/usr/local/apache-ant/bin:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
In my first installation i install the plugins and the plugins directories appear in /plugins/ but after build in iOS only de device plugin appear in /platforms/ios/www/plugins this is the reason that I want to reinstall the plugins.
Anyone know why this is happening and how to resolve it?
回答1:
Finally I solved the problem, first I created the project in local disk. The problem persisted, then I created the project with uppercase in the first letter of project name, and all works fine. Yes, it seems incredible, but this was the solution.
回答2:
I had the same problem after I upgraded to cordova 3.3.0, when I tried 'cordova rm' the plugins (after I removed android.json from the plugins folder). But the problem resolved for me when after I ran 'cordova add' all the plugins.
So I suppose you could try 'cordova plugin list' to see if it knows which plugin is added. if it does know then try removing 'plugins/android.json' then add each of the plugin back in follow by 'cordova build'.
Also if you have angularjs, you might want to remove the /docs for it as it could also produce the error
And you might want to check your /platform/android/project.properties is it using a target that you are expecting? (e.g. android-16 but you don't have it set up?)
回答3:
I had similar issue while installing org.apache.cordova.dialogs plugin. I deleted content under www folder and executed the same command. It worked. Under www folder I had my project which uses Angular. Not sure if angular has any conflict with this.
来源:https://stackoverflow.com/questions/20631138/error-adding-or-deleting-plugins-in-cordova-phone-gap