我试图在我的cordova应用程序中添加一个插件,但是我收到一条错误消息"平台" ios"似乎不是一个有效的cordova平台。它缺少API.js. ios不受支持。"
node --version
v9.2.0
cordova --version
8.0.0
这是我正在运行的命令
cordova plugin add cordova-plugin-appinfo
完整输出:
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.
我确定这是一个有效的Cordova项目,iOS平台似乎运行正常(我可以在iPhone上构建和运行)。
答案 0 :(得分:1)
尝试更新ios平台后遇到相同的错误。 事实证明,node_modules下载缓存中存在一些损坏。 我可以通过再次尝试解决此问题:
let a = [ 1,2,2,3,5,4,2,5,7,9,5,3,8,10 ]
let indices = a.enumerated().withPreviousAndNext.compactMap { values -> Int? in
let (prev, cur, next) = values
return (cur.1 < (prev?.1 ?? Int.min) && cur.1 < (next?.1 ?? Int.min)) ? cur.0 : nil
}
indices // [6,11]
答案 1 :(得分:0)
将文件从一台计算机复制到另一台计算机时出现此错误。
这些行固定
cordova platform rm ios
cordova platform add ios