I'm trying to add a plugin to my cordova app, but I get an error saying "The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported."
node --version
v9.2.0
cordova --version
8.0.0
Here is the command I'm running
cordova plugin add cordova-plugin-appinfo
And the complete output:
Installing "cordova-plugin-appinfo" for ios
Unable to load PlatformApi from platform. Error: Cannot find module 'unorm'
Failed to install 'cordova-plugin-appinfo': Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
at EventEmitter.emit (events.js:140:19)
at EventEmitter.module.exports.emit (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:71:17)
at Object.getPlatformApiFunction (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:499:20)
at Object.getPlatformApi (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js:55:25)
at handleInstall (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:593:29)
at /Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:357:28
at _fulfilled (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:749:13)
at /Users/james/.nvm/versions/node/v9.2.0/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/q/q.js:509:49
(node:35697) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
(node:35697) [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.
I'm certain this is a valid Cordova project and the iOS platform seems to work fine (I can build and run on an iPhone).
I ran into same error after attempting to update ios platform. It turns out there was some corruption in the node_modules download cache. I was able resolve this by trying a second time:
cordova platform rm ios
cordova platform add ios@latest
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With