Search code examples
ioscordovacordova-plugins

Cannot add Cordova plugin - Unhandled promise rejection


I followed this tutorial about how to write Cordova plugin. Now I'm trying to add the plugin into my iOS project like this :

cd /Users/Admin/Desktop/testpluginswift/testapp 
cordova plugin add /Users/Admin/Desktop/testpluginswift/TestPluginSwift/

Then I got this errors :

(node:11661) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError: Invalid Plugin! /Users/Admin/Desktop/testpluginswift/TestPluginSwift/ needs a valid package.json

(node:11661) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

So what I did was :

plugman createpackagejson /Users/Admin/Desktop/testpluginswift/TestPluginSwift/

But now I get this error:

(node:11528) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): CordovaError

(node:11528) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

How can I solve this problems? thanks


Solution

  • You can downgrade the Cordova version to 7.1.0 and use --nofetch option when installing, that way you won't need the package.json file.

    Also, you can provide the package.json that was created so we can see if there is something wrong with it.