我在构建 Ionic 3 应用程序时遇到错误

I'm getting an error when building an Ionic 3 app

我刚刚更新到 Mac Mojave(我确定这是否是我的问题的原因)。

问题是每次我尝试使用命令构建我的应用程序时。

ionic cordova build ios

我收到以下错误。

CordovaError: Promise rejected with non-error: 'ios-deploy was not found. Please download, build and install version 1.9.2 or greater from https://github.com/phonegap/ios-deploy into your path, or do \'npm install -g ios-deploy\''
at cli.catch.err (/usr/local/lib/node_modules/cordova/bin/cordova:30:15)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)

enter code here[错误] 运行 子进程 cordova 时发生错误。

    cordova build ios exited with exit code 1.

    Re-running this command with the --verbose flag may provide more information.

我想我需要安装 ios-deploy 所以我 运行 这个命令。

npm install -g ios-deploy

但是我得到以下错误。

npm ERR! code ELIFECYCLE
npm ERR! errno 65
npm ERR! ios-deploy@1.9.3 preinstall: `./src/scripts/check_reqs.js && xcodebuild`
npm ERR! Exit status 65
npm ERR! 
npm ERR! Failed at the ios-deploy@1.9.3 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alex/.npm/_logs/2018-10-15T15_07_47_819Z-debug.log

我一直在到处寻找答案,但找不到。

在 ionic 论坛中似乎有一个关于这个或非常相似的问题的帖子: ionic forum link

总结一下,XCode 或某些依赖项不在预期位置存在一些问题。

您能否尝试以下操作(如果由于权限原因失败,请添加 sudo):

npm install -g ios-deploy --unsafe-perm=true

已找到修复: sudo npm install --global --unsafe-perm ios-deploy

希望它能对某人有所帮助。 稍后谢谢我。

我也遇到了这个问题。结果我所要做的就是断开我的 iPhone 与 USB 端口的连接。

  1. 断开所有 iOS 设备与 USB 的连接
  2. 构建您的应用并等待它完成
  3. 重新连接设备