NativeScript 安装失败

NativeScript Setup Failed

我在我的终端中 运行 这个命令:

tns doctor --log trace

我得到了这个结果:

execFile: /Users/iyasilias/Library/Android/sdk/platform-tools/adb "help"
execFile: /Users/iyasilias/Library/Android/sdk/platform-tools/adb "help"
spawn: /Users/iyasilias/Library/Android/sdk/platform-tools/adb "--help"
Socket {
  _connecting: false,
  _hadError: false,
  _handle: 
   Pipe {
     bytesRead: 0,
     _externalStream: {},
     fd: 15,
     writeQueueSize: 0,
     owner: [Circular],
     onread: [Function: onread],
     reading: true },
  _parent: null,
  _host: null,
  _readableState: 
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: [],
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: true,
     sync: false,
     needReadable: true,
     emittedReadable: false,
     readableListening: false,
     resumeScheduled: false,
     defaultEncoding: 'utf8',
     ranOut: false,
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: 
   { end: { [Function: g] listener: [Function: onend] },
     finish: [Function: onSocketFinish],
     _socketEnd: [Function: onSocketEnd],
     close: [Function] },
  _eventsCount: 4,
  _maxListeners: undefined,
  _writableState: 
   WritableState {
     objectMode: false,
     highWaterMark: 16384,
     needDrain: false,
     ending: false,
     ended: false,
     finished: false,
     decodeStrings: false,
     defaultEncoding: 'utf8',
     length: 0,
     writing: false,
     corked: 0,
     sync: true,
     bufferProcessing: false,
     onwrite: [Function],
     writecb: null,
     writelen: 0,
     bufferedRequest: null,
     lastBufferedRequest: null,
     pendingcb: 0,
     prefinished: false,
     errorEmitted: false,
     bufferedRequestCount: 0,
     corkedRequestsFree: CorkedRequest { next: null, entry: null, finish: [Function] } },
  writable: false,
  allowHalfOpen: false,
  destroyed: false,
  _bytesDispatched: 0,
  _sockname: null,
  _writev: null,
  _pendingData: null,
  _pendingEncoding: '',
  server: null,
  _server: null }
Exec uname -a 
 stdout: Darwin Muhammads-MacBook-Pro-3.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

 stderr: 
Exec npm -v 
 stdout: 3.6.0

 stderr: 
spawn: java "-version"
Exec node-gyp -v 
 stdout:  
 stderr: /bin/sh: node-gyp: command not found

Exec xcodebuild -version 
 stdout: Xcode 7.3.1
Build version 7D1014

 stderr: 
Exec gem which xcodeproj 
 stdout: /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.24.2/lib/xcodeproj.rb

 stderr: 
Exec pod --version 
 stdout:  
 stderr: /bin/sh: pod: command not found

Exec '/Users/iyasilias/Library/Android/sdk/platform-tools/adb' version 
 stdout: Android Debug Bridge version 1.0.36
Revision 8f855a3d9b35-android

 stderr: 
spawn: /Users/iyasilias/Library/Android/sdk/tools/android "-h"
Result when throw error is false:
{ stdout: '\n       Usage:\n       android [global options] action [action options]\n       Global options:\n  -s --silent     : Silent mode, shows errors only.\n  -v --verbose    : Verbose mode, shows errors, warnings and all messages.\n     --clear-cache: Clear the SDK Manager repository manifest cache.\n  -h --help       : Help on a specific command.\n\n                                                                    Valid\n                                                                    actions\n                                                                    are\n                                                                    composed\n                                                                    of a verb\n                                                                    and an\n                                                                    optional\n                                                                    direct\n                                                                    object:\n-    sdk              : Displays the SDK Manager window.\n-    avd              : Displays the AVD Manager window.\n-   list              : Lists existing targets or virtual devices.\n-   list avd          : Lists existing Android Virtual Devices.\n-   list target       : Lists existing targets.\n-   list device       : Lists existing devices.\n-   list sdk          : Lists remote SDK repository.\n- create avd          : Creates a new Android Virtual Device.\n-   move avd          : Moves or renames an Android Virtual Device.\n- delete avd          : Deletes an Android Virtual Device.\n- update avd          : Updates an Android Virtual Device to match the folders\n                        of a new SDK.\n- create project      : Creates a new Android project.\n- update project      : Updates an Android project (must already have an\n                        AndroidManifest.xml).\n- create test-project : Creates a new Android project for a test package.\n- update test-project : Updates the Android project for a test package (must\n                        already have an AndroidManifest.xml).\n- create lib-project  : Creates a new Android library project.\n- update lib-project  : Updates an Android library project (must already have\n                        an AndroidManifest.xml).\n- create uitest-project: Creates a new UI test project.\n- update adb          : Updates adb to support the USB devices declared in the\n                        SDK add-ons.\n- update sdk          : Updates the SDK by suggesting new platforms to install\n                        if available.\n',
  stderr: '',
  exitCode: 1 }
Exec mono --version 
 stdout: Mono JIT compiler version 4.2.1 (explicit/6dd2d0d Fri Nov  6 12:25:19 EST 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  x86
    Disabled:      none
    Misc:          softdebug 
    LLVM:          yes(3.6.0svn-mono-(detached/a173357)
    GC:            sgen

 stderr: 
Exec git --version 
 stdout: git version 2.6.4

 stderr: 
Exec gradle -v 
 stdout:  
 stderr: /bin/sh: gradle: command not found

Exec "javac" -version 
 stdout:  
 stderr: javac 1.8.0_102

System information:
{ procInfo: 'nativescript/2.2.1',
  platform: 'darwin',
  os: 'Darwin Muhammads-MacBook-Pro-3.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64\n',
  shell: '/bin/bash',
  dotNetVer: null,
  procArch: 'x64',
  nodeVer: 'v4.5.0',
  npmVer: '3.6.0',
  javaVer: '1.8.0',
  nodeGypVer: null,
  xcodeVer: 'Xcode 7.3.1\nBuild version 7D1014\n',
  xcodeprojGemLocation: '/Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.24.2/lib/xcodeproj.rb\n',
  itunesInstalled: true,
  cocoapodVer: null,
  adbVer: 'Android Debug Bridge version 1.0.36',
  androidInstalled: true,
  monoVer: '4.2.1',
  gitVer: '2.6.4',
  gradleVer: null,
  javacVersion: '1.8.0_102' }
Looking for project in '/Users/iyasilias'
Looking for project in '/Users'
Looking for project in '/'
No project found at or above '/Users/iyasilias'.
No project found at or above '%s' and neither was a --path specified.
Initializing analytics statuses.
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track feature 'CLI' with value 'doctor'.
execFile: /Users/iyasilias/Library/Android/sdk/platform-tools/adb "help"
WARNING: CocoaPods is not installed or is not configured properly.
You will not be able to build your projects for iOS if they contain plugin with CocoaPod file.
To be able to build such projects, verify that you have installed CocoaPods.
Exec pod --version 
 stdout:  
 stderr: /bin/sh: pod: command not found

Exec xcodebuild -version 
 stdout: Xcode 7.3.1
Build version 7D1014

 stderr: 
spawn: /Users/iyasilias/Library/Android/sdk/tools/android "list" "targets"
Result when throw error is false:
{ stdout: 'Available Android targets:\n----------\nid: 1 or "android-13"\n     Name: Android 3.2\n     Type: Platform\n     API level: 13\n     Revision: 1\n     Skins: WXGA (default)\n Tag/ABIs : default/armeabi\n----------\nid: 2 or "android-14"\n     Name: Android 4.0\n     Type: Platform\n     API level: 14\n     Revision: 4\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800\n Tag/ABIs : no ABIs.\n----------\nid: 3 or "android-15"\n     Name: Android 4.0.3\n     Type: Platform\n     API level: 15\n     Revision: 5\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800\n Tag/ABIs : no ABIs.\n----------\nid: 4 or "android-16"\n     Name: Android 4.1.2\n     Type: Platform\n     API level: 16\n     Revision: 5\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 5 or "android-17"\n     Name: Android 4.2.2\n     Type: Platform\n     API level: 17\n     Revision: 3\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 6 or "android-18"\n     Name: Android 4.3.1\n     Type: Platform\n     API level: 18\n     Revision: 3\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 7 or "android-19"\n     Name: Android 4.4.2\n     Type: Platform\n     API level: 19\n     Revision: 4\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 8 or "android-20"\n     Name: Android 4.4W.2\n     Type: Platform\n     API level: 20\n     Revision: 2\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 9 or "android-21"\n     Name: Android 5.0.1\n     Type: Platform\n     API level: 21\n     Revision: 2\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 10 or "android-22"\n     Name: Android 5.1.1\n     Type: Platform\n     API level: 22\n     Revision: 2\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 11 or "android-23"\n     Name: Android 6.0\n     Type: Platform\n     API level: 23\n     Revision: 3\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : no ABIs.\n----------\nid: 12 or "android-24"\n     Name: Android 7.0\n     Type: Platform\n     API level: 24\n     Revision: 2\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin320x300, AndroidWearRoundChin360x325, AndroidWearRoundChin360x326, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare240x240, AndroidWearSquare320x320, AndroidWearRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin320x300, AndroidWearRoundChin360x325, AndroidWearRoundChin360x326, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare240x240, AndroidWearSquare320x320\n Tag/ABIs : android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/arm64-v8a, default/armeabi-v7a, default/x86, default/x86_64\n----------\nid: 13 or "Google Inc.:Google APIs:21"\n     Name: Google APIs\n     Type: Add-On\n     Vendor: Google Inc.\n     Revision: 1\n     Description: Android + Google APIs\n     Based on Android 5.0.1 (API level 21)\n     Libraries:\n      * com.android.future.usb.accessory (usb.jar)\n          API for USB Accessories\n      * com.google.android.media.effects (effects.jar)\n          Collection of video effects\n      * com.google.android.maps (maps.jar)\n          API for Google Maps\n     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in\n Tag/ABIs : google_apis/x86\n',
  stderr: '',
  exitCode: 0 }
Available Android targets:
----------
id: 1 or "android-13"
     Name: Android 3.2
     Type: Platform
     API level: 13
     Revision: 1
     Skins: WXGA (default)
 Tag/ABIs : default/armeabi
----------
id: 2 or "android-14"
     Name: Android 4.0
     Type: Platform
     API level: 14
     Revision: 4
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
 Tag/ABIs : no ABIs.
----------
id: 3 or "android-15"
     Name: Android 4.0.3
     Type: Platform
     API level: 15
     Revision: 5
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800
 Tag/ABIs : no ABIs.
----------
id: 4 or "android-16"
     Name: Android 4.1.2
     Type: Platform
     API level: 16
     Revision: 5
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 5 or "android-17"
     Name: Android 4.2.2
     Type: Platform
     API level: 17
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 6 or "android-18"
     Name: Android 4.3.1
     Type: Platform
     API level: 18
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 7 or "android-19"
     Name: Android 4.4.2
     Type: Platform
     API level: 19
     Revision: 4
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 8 or "android-20"
     Name: Android 4.4W.2
     Type: Platform
     API level: 20
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 9 or "android-21"
     Name: Android 5.0.1
     Type: Platform
     API level: 21
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 10 or "android-22"
     Name: Android 5.1.1
     Type: Platform
     API level: 22
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 11 or "android-23"
     Name: Android 6.0
     Type: Platform
     API level: 23
     Revision: 3
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.
----------
id: 12 or "android-24"
     Name: Android 7.0
     Type: Platform
     API level: 24
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin320x300, AndroidWearRoundChin360x325, AndroidWearRoundChin360x326, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare240x240, AndroidWearSquare320x320, AndroidWearRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin320x300, AndroidWearRoundChin360x325, AndroidWearRoundChin360x326, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare240x240, AndroidWearSquare320x320
 Tag/ABIs : android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/arm64-v8a, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 13 or "Google Inc.:Google APIs:21"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 5.0.1 (API level 21)
     Libraries:
      * com.android.future.usb.accessory (usb.jar)
          API for USB Accessories
      * com.google.android.media.effects (effects.jar)
          Collection of video effects
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : google_apis/x86

Directories found in /Users/iyasilias/Library/Android/sdk/build-tools are 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1
Versions found in /Users/iyasilias/Library/Android/sdk/build-tools are 19.1.0, 20.0.0, 21.1.2, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1
Selected version is:  23.0.3
Selected targetSdk is: 23
Directories found in /Users/iyasilias/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7 are 18.0.0, 19.0.0, 19.0.1, 19.1.0, 20.0.0, 21.0.0, 21.0.2, 21.0.3, 22.0.0, 22.1.0, 22.1.1, 22.2.0, 22.2.1, 23.0.0, 23.0.1, 23.1.0, 23.1.1, 23.2.0, 23.2.1, 23.3.0, 23.4.0, 24.0.0, 24.0.0-alpha1, 24.0.0-alpha2, 24.0.0-beta1, 24.1.0, 24.1.1, 24.2.0, maven-metadata.xml, maven-metadata.xml.md5, maven-metadata.xml.sha1
Versions found in /Users/iyasilias/Library/Android/sdk/extras/android/m2repository/com/android/support/appcompat-v7 are 18.0.0, 19.0.0, 19.0.1, 19.1.0, 20.0.0, 21.0.0, 21.0.2, 21.0.3, 22.0.0, 22.1.0, 22.1.1, 22.2.0, 22.2.1, 23.0.0, 23.0.1, 23.1.0, 23.1.1, 23.2.0, 23.2.1, 23.3.0, 23.4.0, 24.0.0, 24.0.0, 24.0.0, 24.0.0, 24.1.0, 24.1.1, 24.2.0
Selected version is:  23.4.0
Selected AppCompat version is: 23.4.0
Analytics statuses: 
{ TrackFeatureUsage: 1, TrackExceptions: 1 }
Trying to track feature 'DoctorEnvironmentSetup' with value 'incorrect'.
There seem to be issues with your configuration.

如果我 运行 安装脚本,我无法安装 xcodeproj 和 cocoapods

注意:第一个 $ANDROID_HOME 路径问题已经解决,感谢 Dennis Tang

请帮忙..

这可能无法解决您所有的设置问题,但对于 $ANDROID_HOME 环境变量,您可能需要查看以下答案: https://askubuntu.com/a/266760(注意他们使用变量ANDROID_SDK_HOME,确保你的变量名是ANDROID_HOME!)

一旦您设置了 .profile 文件和 source .profile(如该答案中所述)并重新启动您的系统,$ANDROID_HOME 应该始终指向您的路径 /Users/iyasilias/Library/Android/sdk

假设您已在该文件夹中正确安装 SDK,tns doctor 之后应该会检测到 Android SDK 文件夹。

特别是 $ANDROID_HOME 问题,您需要将 export ANDROID_HOME=/Users/iyasilias/Library/Android/sdk 添加到 ~/.bash_profile 以使其在终端会话中持续存在。

鉴于您在使用 abd 和 Cocoapods 时遇到问题,我建议 运行 重新设置 NativeScript 以让它尝试正确安装所有内容:ruby -e "$(curl -fsSL https://www.nativescript.org/setup/mac)"

编辑 xcodeproj 和 cocoapods

您应该在 http://docs.nativescript.org/angular/start/ns-setup-os-x

查看高级安装说明

具体来说,第 3 步的第 1-4 步(混淆了他们如何将编号列表嵌套在编号列表中),但它是确保 Xcode 和 [=32 的命令行工具的选项=] 已安装。

从那里,你可以安装 gems,不过如果你在 OS X El Capitan 上,我会使用 sudo gem install -n /usr/local/bin xcodeproj cocoapods 而不是普通的 sudo gem install 因为 SIP 阻止你在 /usr/bin.

中安装 gems

希望在那之后你应该一切顺利!

NativeScript 安装失败?

至于 $ANDROID_HOME,请按照 Dennis Tang 的建议将 export ANDROID_HOME=/Users/iyasilias/Library/Android/sdk 插入您的 ~/.bash_profile

至于 Cocoapods 总是安装失败,我是因为 OS 我正在使用 (El Capitan)。解决方案是创建自定义 GEM_HOME

$ mkdir -p $HOME/Software/ruby
$ export GEM_HOME=$HOME/Software/ruby
$ gem install cocoapods
[...]
1 gem installed
$ export PATH=$PATH:$HOME/Software/ruby/bin
$ pod --version

来源:https://github.com/CocoaPods/CocoaPods/issues/3692