我一直在尝试开始使用 Ionic Framework,其中一个步骤是安装 Cordova。
sudo npm install -g cordova
运行正常。然后我必须添加 iOS 和 Android 平台,但在尝试添加时出现错误:
苹果系统:
benedict@prometheus:/var/www/ionic/hello$ sudo cordova platform add ios
Creating ios project...
/home/benedict/.cordova/lib/ios/cordova/3.4.0/bin/create: 33: /home/benedict/.cordova/lib/ios/cordova/3.4.0/bin/create: Syntax error: "(" unexpected
Error: /home/benedict/.cordova/lib/ios/cordova/3.4.0/bin/create: Command failed with exit code 2
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
安卓:
benedict@prometheus:/var/www/ionic/hello$ sudo cordova platform add android
Creating android project...
/home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/benedict/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/home/benedict/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
Error: /home/benedict/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/lib/node_modules/cordova/src/superspawn.js:112:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
我尝试重新安装 Cordova,但无济于事。知道问题出在哪里吗?
答案1
不确定 ios 错误(linux 支持吗?- 当您执行“cordova 平台列表”时,它不在可用平台列表中)。可能需要额外安装和 Apple dev 证书。
至于 Android 错误 - 您应该能够修复它:
检查你的 ant 安装是否响应“ant -version”。
查看此答案以了解如何在 Linux 中设置所需的路径,并使用文件资源管理器仔细检查所有路径:https://stackoverflow.com/a/21142421
确保注销/登录以应用路径。
还要使用“echo $PATH”检查您的路径是否与您认为的一致。